#33420: cannot import name 'RequestSite' from partially initialized module
'django.contrib.sites.requests' (most likely due to a circular import)
-----------------------------------------------+------------------------
Reporter: Raphaël Hertzog | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.syndication | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
In a website that has always been working fine, I have started to get
occasional errors in codepath that use contrib.syndication.views:
{{{
File "/usr/lib/python3/dist-packages/django/core/handlers/exception.py" in
inner
34. response = get_response(request)
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py" in
_get_response
115. response = self.process_exception_by_middleware(e,
request)
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py" in
_get_response
113. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File "/usr/lib/python3/dist-packages/django/contrib/syndication/views.py"
in __call__
39. feedgen = self.get_feed(obj, request)
File "/usr/lib/python3/dist-packages/django/contrib/syndication/views.py"
in get_feed
127. current_site = get_current_site(request)
File "/usr/lib/python3/dist-packages/django/contrib/sites/shortcuts.py" in
get_current_site
15. from .requests import RequestSite
Exception Type: ImportError at /pkg/gdb/rss
Exception Value: cannot import name 'RequestSite' from partially
initialized module 'django.contrib.sites.requests' (most likely due to a
circular import)
(/usr/lib/python3/dist-packages/django/contrib/sites/requests.py)
}}}
Note that in the Django configuration, I do not enable the
django.contrib.sites application. This seems to be in line with the
django.contrib.syndication doc saying that if you don't have the
django.contrib.sites application you get a RequestSite object instead.
FWIW the view is here: https://salsa.debian.org/qa/distro-
tracker/-/blob/master/distro_tracker/core/news_feed.py#L37
And this is about https://tracker.debian.org
This is reproduced with Django 2.2.25 (Debian package python3-django
2:2.2.25-1~deb11u1) and I know it's relatively old. But I find it weird
that this problem started to appear recently (or at least get more
frequent) since the website has been upgraded to run on Debian 11 instead
of Debian 10 (the Django major version has not changed, but the Python
version went to 3.9 and the dependencies have been upgraded too). Or it
might be related to some recent updates within 2.2.x but that seems
unlikely since it's only security updates at this point.
As a wild guess, the underlying reason is more likely to be related to
changes in Python 3.9 import logic.
--
Ticket URL: <https://code.djangoproject.com/ticket/33420>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.9ba560c60b0e86ceb4d7f5be699c8991%40djangoproject.com.