Opened 8 months ago

Last modified 8 months ago

#35426 closed Bug

`GenericPrefetch` should have `queryset` parameter as required — at Initial Version

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

Original issue: https://code.djangoproject.com/ticket/33651

Source: https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7

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 (0)

Note: See TracTickets for help on using tickets.
Back to Top