You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When subclassing django.forms.ModelChoiceField and overriding label_from_instance(), the type of the method argument is Model, but the implementation likely needs to know which concrete model type is being passed.
How is that should be
While it is possible to work around this using cast() or assert isinstance(), having a type argument for the model type (_M) on ModelChoiceField would be a more elegant solution.
System information
django version: 3.2.6
django-stubs version: 1.8.0
The text was updated successfully, but these errors were encountered:
Bug report
What's wrong
When subclassing
django.forms.ModelChoiceField
and overridinglabel_from_instance()
, the type of the method argument isModel
, but the implementation likely needs to know which concrete model type is being passed.How is that should be
While it is possible to work around this using
cast()
orassert isinstance()
, having a type argument for the model type (_M
) onModelChoiceField
would be a more elegant solution.System information
django
version: 3.2.6django-stubs
version: 1.8.0The text was updated successfully, but these errors were encountered: