{{{
$ ./manage.py sqlall myapp
Traceback (most recent call last):
File "<project>/settings.py", line 2, in <module>
from .settings_local import *
File "<project>/settings_local.py", line 1, in <module>
from .settings_base import *
File "<project>/settings_base.py", line 5, in <module>
from django.core.urlresolvers import reverse_lazy
File "<virtualenv>/src/django/django/core/urlresolvers.py", line 15, in
<module>
from django.http import Http404
File "<virtualenv>/src/django/django/http/__init__.py", line 4, in
<module>
from django.http.response import (HttpResponse, StreamingHttpResponse,
File "<virtualenv>/src/django/django/http/response.py", line 17, in
<module>
from django.core.serializers.json import DjangoJSONEncoder
File "<virtualenv>/src/django/django/core/serializers/__init__.py", line
23, in <module>
from django.core.serializers.base import SerializerDoesNotExist
File "<virtualenv>/src/django/django/core/serializers/base.py", line 6,
in <module>
from django.db import models
ImportError: cannot import name models
}}}
Marking as a release blocker as discussed with apollo13 in IRC.
Cause of this regression is commit:
https://github.com/django/django/commit/0242134d32aa99a54442211ed05576b7061866d1
--
Ticket URL: <https://code.djangoproject.com/ticket/22057>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Marking as accepted as discussed with apollo13
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:1>
Comment (by gnosek):
Cannot reproduce even though there is a clear circular import. Does
anybody have a self-contained app showing the problem?
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:2>
Comment (by dfunckt):
I attached a test project. Using Django@master, Python 3.3.
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:3>
Comment (by dfunckt):
Added a quick patch that fixes the issue. Run tests with sqlite, all pass.
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:4>
Comment (by anonymous):
I think it's better to just move the !DjangoJSONEncoder into the
JSONResponse
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:5>
Comment (by dfunckt):
Added another patch, fixing the issue by lazily importing
{{{DjangoJSONEncoder}}} inside {{{JSONResponse.__init__}}}.
I'm not sure how to go about testing for this regression in order to
provide a complete patch, so if anyone has any pointers it would help.
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:6>
Comment (by aaugustin):
Such patches are fragile. We try to keep imports properly ordered at the
top of modules. After a few years it becomes unclear why a specific import
doesn't happen at module level, and if it's still needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:7>
Comment (by claudep):
I think the problem is caused by two lines here:
https://github.com/django/django/blob/master/django/db/models/sql/aggregates.py#L14-15
It shouldn't be too difficult to defer these instanciations. I'll attach a
patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:8>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"45edb9d2359c60952fd791616df887eb95f75746"]:
{{{
#!CommitTicketReference repository=""
revision="45edb9d2359c60952fd791616df887eb95f75746"
Fixed #22057 -- Ensured reverse_lazy can be used in settings
And without causing a circular import. Thanks Akis Kesoglou for
the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22057#comment:9>