I've used named URLs for some time now, never had any trouble with
them.
But now I have added an app 'website' to a new Django project.
(version 1.1 beta 1 SVN-10924)
My root urlconf (as defined in settings.py) contains an include to
website.urls:
---
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^$', include('website.urls')),
)
---
The included urlconf website.urls looks like this:
---
from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('',
url(r'search/', 'website.views.search', name='website-search'),
url(r'^$', 'website.views.index', name='website-index'),
)
---
And both view functions exist ofcourse:
---
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
def index(request):
"""
docstring for index
"""
return render_to_response("website/index.html", locals(),
context_instance=RequestContext(request))
def search(request):
"""
docstring for search
"""
return render_to_response("website/search.html", locals(),
context_instance=RequestContext(request))
---
The problem is that the {% url website-search %} tags don't work. They
give this error:
---
TemplateSyntaxError at /
Caught an exception while rendering: Reverse for 'website-search' with
arguments '()' and keyword arguments '{}' not found.
---
But if I move the 'search' entry to the root urlconf, it works..
---
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
url(r'search/', 'website.views.search', name='website-search'),
(r'^$', include('website.urls')),
)
---
I'd rather have this entry in the included urlconf. This worked in the
past..
I don't understand why this won't work. What am I not seeing? Thanks
for any help!
Gijs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---