Open adnathanail opened 2 years ago
I have a model with a many to many field, and a model form pointing to that model.
In the __init__ on that model I want to override the queryset for the many to many field, but I get error: "Field" has no attribute "queryset"
__init__
queryset
error: "Field" has no attribute "queryset"
I think this is because .queryset only exists on ModelChoiceField
.queryset
ModelChoiceField
Is there anyway I can type hint this correctly? Or does anyone have a suggestion for a PR that I could try to write?
I have made a minimal reproduction, it is the only failing test in this fork:
https://github.com/adnathanail/django-stubs/actions/runs/3430356832/jobs/5717214486
The tests on that repo should pass
python
django
mypy
django-stubs
django-stubs-ext
I think this issue could be related #1054
Bug report
What's wrong
I have a model with a many to many field, and a model form pointing to that model.
In the
__init__
on that model I want to override thequeryset
for the many to many field, but I geterror: "Field" has no attribute "queryset"
I think this is because
.queryset
only exists onModelChoiceField
Is there anyway I can type hint this correctly? Or does anyone have a suggestion for a PR that I could try to write?
I have made a minimal reproduction, it is the only failing test in this fork:
https://github.com/adnathanail/django-stubs/actions/runs/3430356832/jobs/5717214486
How is that should be
The tests on that repo should pass
System information
python
version: 3.10django
version: 3.2.15mypy
version: 0.971django-stubs
version: 1.12.0django-stubs-ext
version: 0.5.0