问题
I have a little problem with project upgrade from Django 1.7.1 to 1.9.0. Every 'RemovedInDjango20Warning' has been fixed, but one thing still left and I don't know how to deal with it.
When I'm trying to visit any page, there is always an ImportError like:
**TemplateSyntaxError at /auth/**
'crispy_forms_tags' is not a valid tag library:
ImportError raised loading crispy_forms.templatetags.crispy_forms_tags:
cannot import name memoize***
I have included {% load crispy_forms_tags %}
in my template site, and added 'crispy_forms' in INSTALLED_APPS
in settings.py
I tried to find any solution, but without success, before the update worked fine.
What am I doing wrong?
回答1:
You are using a pre-release version of Django which Crispy Forms doesn't yet support.
You should either switch to a Django version which Crispy Forms does support, stop using Crispy Forms, or patch it yourself so it works with the newer Django version.
回答2:
The reason for this error, as has been stated, is that Django dropped memoize at some point, so the version of crispy-forms you were trying to use was not working with the Django version.
Solutions include trying a different version of Django, or trying a different version of crispy-forms. If you are using an unreleased version of Django, then there may not be a version of cripsy that supports it (yet).
However, your error ("cannot import name memoize"), can show up for released versions of Django - I had that error, and a search lead me to this ticket. The issue was that i was using an old version of crispy (1.4.1), and a recent version of Django (1.11.1).
To find a version of crispy to use, you can check the github release page:
https://github.com/django-crispy-forms/django-crispy-forms/releases
The release comments include some information about the Django version supported by different releases.
来源:https://stackoverflow.com/questions/30308267/importerror-cannot-import-name-memoize