I'm very new to python and trying to run a piece of Django code on my system, but I'm running into this problem.
$ python manage.py runserver
Running in development mode.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
import settings
File "/Users/Kinnovate/Desktop/fsdjango/platformsite/settings.py", line 321, in <module>
from django.core.urlresolvers import reverse_lazy
ImportError: cannot import name reverse_lazy
I'm using python 2.7. How do I fix this?
reverse_lazy
is newer than any released version of Django. Are you sure you have a trunk version of Django?
if you're stuck with 1.3 for a while you can use something along these lines:
try:
from django.core.urlresolvers import reverse_lazy
except ImportError:
from django.core.urlresolvers import reverse
from django.utils.functional import lazy
reverse_lazy = lambda *args, **kwargs: lazy(reverse, str)(*args, **kwargs)
Update: reverse_lazy handling variable args
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With