Skip to content

Conversation

intgr
Copy link
Collaborator

@intgr intgr commented Sep 29, 2022

Previously mypy_django_plugin would always use the field type of target model's primary key, but to_field can refer to a different field type.

Previously mypy_django_plugin would always use the field type of target
model's primary key, but `to_field` can refer to a different field type.
if to_field_name:
rel_field = related_model_cls._meta.get_field(to_field_name)
if not isinstance(rel_field, Field):
return None # Not supported
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's referring to a non-field, Django system checks would probably throw an error. I could also use assert here.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Thank you!

@sobolevn sobolevn merged commit db14454 into typeddjango:master Sep 30, 2022
@intgr
Copy link
Collaborator Author

intgr commented Sep 30, 2022

@sobolevn Thanks for your continued maintenance.

There is already tons of good stuff merged in django-stubs, any plans for a release?

@sobolevn
Copy link
Member

Yes! Soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants