#35426 closed Bug (fixed)
`GenericPrefetch` should have `queryset` parameter as required
Reported by: | Sobolev Nikita | Owned by: | Sobolev Nikita |
---|---|---|---|
Component: | contrib.contenttypes | Version: | 5.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Sobolev Nikita | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Original issue: https://code.djangoproject.com/ticket/33651
Right now this code is really strange. It produces this result:
>>> import django >>> from django.contrib.contenttypes.prefetch import GenericPrefetch >>> GenericPrefetch('a') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/sobolev/Documents/github/wemake-django-template/.venv/lib/python3.11/site-packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__ for queryset in querysets: TypeError: 'NoneType' object is not iterable
I guess that there are two ways:
- Using
if querysets is None: querysets = []
- Requiring this argument, which I guess is the correct thing to do. Why would we ever want this field to be empty?
I will send a PR with the fix.
I found this while working on https://github.com/typeddjango/django-stubs/pull/2115
Change History (6)
comment:1 by , 5 months ago
Description: | modified (diff) |
---|
comment:2 by , 5 months ago
Has patch: | set |
---|
comment:3 by , 5 months ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:6 by , 5 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Hi Sobelev, thank you for the report and patch!
Agreed this is a bug in cac94dd8aa2fb49cd2e06b5b37cf039257284bb0, as this is a new feature introduced in 5.0, marking as a release blocker.