Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] name collisions when defining fields with the same choices class name #1367

Open
Zerotask opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@Zerotask
Copy link
Contributor

Zerotask commented Dec 19, 2024

Describe the bug
I have 2 schemas which are not related to each other.
Both are ModelSchemas with a status field and both have a type annotation for it:

status: OrganizationRelation.StatusChoices
...
status: ReportStatus.StatusChoices

StatusChoices is a subclass of a regular django model.

This results in a generated StatusChoices schema which is the same for both.
This means, that every field which have a StatusChoices will display the wrong values.

The proposed solution would be to include the parent class name:

  • OrganizationRelationStatusChoices
  • ReportStatusStatusChoices

Alternatively give the option to define a name for the generated schema field.

Since it is a sub-class, you can't import it as an alias and defining a variable like OrganizationRelationStatusChoices = OrganizationRelation.StatusChoices also results in a StatusChoices schema generated.

Versions (please complete the following information):

  • Python version: 3.13.1
  • Django version: 5.0
  • Django-Ninja version: 1.3.0
  • Pydantic version: 2.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant