Skip to content

Reversed naming for OneToManyInput & ManyToOneInput #826

@niekheinen

Description

@niekheinen

The input types OneToManyInput and ManyToOneInput in Strawberry-Django appear to use terminology that is reversed relative to Django’s relationship definitions. This can cause confusion for developers familiar with Django’s ORM semantics.

According to the Django documentation:

To define a many-to-one relationship, use ForeignKey.

However, in strawberry_django/fields/types.py the following mapping is defined:

input_field_type_map = {
  ...
  related.ForeignKey: OneToManyInput,
  reverse_related.ManyToOneRel: ManyToOneInput,
  ...
}

The naming appears to be reversed. If you agree, I’d be happy to open a PR to fix it. It looks like we would only need to swap the class names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions