8π
Hereβs a solution to the problem I found here:
http://andr.in/2009/11/21/calling-reverse-in-django/
I have pasted the code snippet below in case that link disappears:
from django.conf.urls.defaults import * from django.core.urlresolvers import reverse from django.utils.functional import lazy from django.http import HttpResponse reverse_lazy = lazy(reverse, str) urlpatterns = patterns('', url(r'^comehere/', lambda request: HttpResponse('Welcome!'), name='comehere'), url(r'^$', 'django.views.generic.simple.redirect_to', {'url': reverse_lazy('comehere')}, name='root') )
2π
Django 1.4 Alpha includes a function reverse_lazy
to help with this problem.
1π
You have a typo β no opening quote before post_save_redirect
. Also, have you imported list_detail
and create_update
since you are referring to the modules directly, rather than as strings?
Edited I suspect that the problem comes from having a call to reverse
in the partners_add
dictionary. I think this will lead to a circular dependency, since the urlconf now depends on attributes which have not yet been defined at the time the urlconf is imported.
Try removing that call β perhaps hard-code the relevant url β and see if it works.
0π
One way it would work would be to wrap create_object function and use reverse from the views.py.
In urls.py code could look something like this:
urlpatterns = patterns('',
url(r'^foo/$', list_detail.object_list, foo_list, name='foo-list'),
url(r'^foo/add/$','myapp.views.my_create_object', name='foo-add'),
)
and in myapp/views.py
from django.views.generic.create_update import create_object
from feincms.content.application.models import reverse
from forms import FooForm
def my_create_object(request):
return create_object(request, form_class=FooForm,
post_save_redirect=reverse("foo-list"))
- [Django]-Django admin β OneToOneField inline throws "has no ForeignKey" exception
- [Django]-Django method to change User email not working
- [Django]-Json.parse gives Uncaught SyntaxError: Unexpected Token (Django json serialized queryset)
- [Django]-How to read Django request.FILES (which is an image) as binary
- [Django]-Css not working with FastCGI and Lighttpd