If you did tried to use
reverse function to set
success_url in class based generic views and you have got an exception, this helper function may help.
Put this snipped in some file, for example utils.py and import this function.
1 2 3 4 5 6
from django.utils.functional import lazy from django.core.urlresolvers import reverse # Workaround for using reverse with success_url in class based generic views # because direct usage of it throws an exception. reverse_lazy = lambda name=None, *args : lazy(reverse, str)(name, args=args)
More like this
- Serializer factory with Django Rest Framework by julio 5 months, 3 weeks ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 6 months, 1 week ago
- Help text hyperlinks by sa2812 7 months, 1 week ago
- Stuff by NixonDash 9 months, 2 weeks ago
- Add custom fields to the built-in Group model by jmoppel 11 months, 2 weeks ago