Django: import error that refer to template tags
I'm having a headache with some errors that appear suddenly on an application I'm developing. One time I solved it using complete imports (including the project dir) but this time the error has no sense.
TemplateSyntaxError at /accounts/login/
Caught ViewDoesNotExist while rendering: Could not import e_cidadania.apps.proposals.views. Error was: cannot import name User
And marked code is:
<a href="{% url password_reset %}">{% trans "Lost you开发者_JS百科r password?" %}</a>
The import line at views.py:24
from django.contrib.auth.models import User
I must say, 24h before everything was working fine and no changes were made to the repo.
I've looked the url and the view, both are fine. I've run manage.py shell
and tested the import, works fine. I did put some markers in the code to test how it was running and the program crashes exactly importing the User
model in that file (there are lots of imports User in the application and not one of them gave a warning). Even deleting the import from thefile gives the same error!
How can I track this to know what is the real problem?
UPDATE: I forgot to mention that the marked error is in the userprofile
module, and the proper error is given in the proposals
module, a module that has absolutely nothing to do with userprofile.
UPDATE 2: You can see the code here, the application is GPL so there is no problem.
The "relation" between userprofile and proposals modules is that you probably refer to both in the urls definition, which is used to do the reverse when using {% url 'whatever.viewname' [args] %} there probably you do import some view function from both.
I would start having a look at modules you're importing there.
I had this annoying problem (more than once) and most of the time it was caused by recursive imports or by a order dependent imports that I was not aware of (because most of the times "was working").
精彩评论