Django url tag : maximum recursion depth exceeded
I'm struggling around the following problem:
I've two urls files :
The root one :
urlpatterns = patterns('',
...
(r'^demonstrator/', include('powernest.demonstrator.urls')),
开发者_如何学运维 ...
)
and the application one :
urlpatterns += patterns('demonstrator.views',
...
url(r'^demonstrator/choices/$', 'demo_choices', d_demo_choice, name="demo_choices"),
...
)
The associated view :
def demo_choices(request, template_name, action):
...
return render_to_response(template_name, datas, context_instance=RequestContext(request))
When I try to call the named url "demo_choices" in a template, thanks to {% url demo_choices %} I get a TemplateSyntaxError exception :
Caught an exception while rendering: maximum recursion depth exceeded while calling a Python object
I have spent much time without figuring it out! please help !
Thank you and sorry for my poor english!
Victor
You are including your app.urls and using +=
in your app urls.py. This is causing the max recursion depth exceeded errors.
Leave your urls.py as it is and change your app/urls.py to:
urlpatterns = patterns('demonstrator.views',
...
url(r'^choices/$', 'demo_choices', d_demo_choice, name="demo_choices"),
...
)
Note that you don't really need that extra "demonstrator" part in the url regex. Hope that helps.
精彩评论