Check out the description of the {% url %} tag in the Django documentation:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url It does not expect the project name to be in the URL. Try dropping "gpp" and just use "weblinks.views.view_links". On Sep 15, 9:19 pm, Brian Neal <[EMAIL PROTECTED]> wrote: > This is my urls.py for an app (notice the two that start with > ^category/, they both vector to my function view_links): > > from django.conf.urls.defaults import * > > urlpatterns = patterns('gpp.weblinks.views', > (r'^$', 'link_index'), > (r'^add/$', 'add_link'), > (r'^category/(?P<category>\d+)/$', 'view_links'), > (r'^category/(?P<category>\d+)/(?P<sort>title|date|rating|hits)/(? > P<dir>up|down)/(?P<page>\d+)/$', 'view_links'), > (r'^new/$', 'new_links'), > (r'^popular/$', 'popular_links'), > (r'^random/$', 'random_link'), > (r'^top_rated/$', 'top_rated_links'), > (r'^visit/(\d+)/$', 'visit'), > ) > > This is my signature for my function view_links in gpp.weblinks.views: > > def view_links(request, category, sort = 'title', dir = 'up', page = > '1'): > > If I type these links manually into my browser, they both work. Each > exercises one of my urlpatterns that start with category: (note that I > have a parent urls.py that looks for "^links/" and then includes the > above urls.py) > > http://localhost:8000/links/category/1/http://localhost:8000/links/category/1/title/up/2/ > > However when I try to then add the following bit of stuff to my > template, then visithttp://localhost:8000/links/category/1/, I get an > error. > > {% if page.has_next %} > <a href="{% url gpp.weblinks.views.view_links > category=category.id,sort=s,dir=d,page=page.next_page_number %}"> > Next Page</a> > {% endif %} > > Here is Traceback for the error that I get. Notice that in the error > message it says this: "Reverse for > 'gpp.gpp.weblinks.views.view_links' ... ". Why is gpp on there twice? > It should just be gpp.weblinks.views.view_links. Anyway, here it is: > > Environment: > > Request Method: GET > Request URL:http://localhost:8000/links/category/1/ > Django Version: 1.0-final-SVN-unknown > Python Version: 2.5.2 > Installed Applications: > ['django.contrib.admin', > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'gpp.core', > 'gpp.accounts', > 'gpp.legal', > 'gpp.contact', > 'gpp.weblinks'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > Template error: > In template d:\documents\brian\coding\python\django\gremmies_portal\gpp > \templates\gpp\weblinks\view_links.html, error at line 8 > Caught an exception while rendering: Reverse for > 'gpp.gpp.weblinks.views.view_links' with arguments '()' and keyword > arguments '{'category': 1L, 'sort': 'title', 'page': 2, 'dir': 'up'}' > not found. > 1 : {% extends 'gpp/weblinks/base.html' %} > > 2 : {% block title %}Web Links: {{ category.title }}{% endblock %} > > 3 : {% block weblinks_content %} > > 4 : <h2>Category: {{ category.title }}</h2> > > 5 : {% if page.object_list %} > > 6 : <p> > > 7 : {% if page.has_next %} > > 8 : <a href=" {% url gpp.weblinks.views.view_links > category=category.id,sort=s,dir=d,page=page.next_page_number %} "> > > 9 : Next Page</a> > > 10 : {% endif %} > > 11 : </p> > > 12 : <dl> > > 13 : {% for link in page.object_list %} > > 14 : <dt> > > 15 : <a href="{% url gpp.weblinks.views.visit link.id %}" > target="_blank">{{ link.title }}</a> > > 16 : </dt> > > 17 : <dd> > > 18 : <p>{{ link.description }}</p> > > Traceback: > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in > get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "D:\Documents\Brian\Coding\Python\django\gremmies_portal\gpp\.. > \gpp\weblinks\views.py" in view_links > 86. context_instance = RequestContext(request)) > File "C:\Python25\lib\site-packages\django\shortcuts\__init__.py" in > render_to_response > 18. return HttpResponse(loader.render_to_string(*args, > **kwargs), **httpresponse_kwargs) > File "C:\Python25\lib\site-packages\django\template\loader.py" in > render_to_string > 107. return t.render(context_instance) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 176. return self.nodelist.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in > render > 97. return compiled_parent.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 176. return self.nodelist.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in > render > 97. return compiled_parent.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 176. return self.nodelist.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in > render > 24. result = self.nodelist.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in > render > 24. result = self.nodelist.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\Lib\site-packages\django\template\defaulttags.py" in > render > 245. return self.nodelist_true.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 71. result = node.render(context) > File "C:\Python25\Lib\site-packages\django\template\defaulttags.py" in > render > 245. return self.nodelist_true.render(context) > File "C:\Python25\Lib\site-packages\django\template\__init__.py" in > render > 768. bits.append(self.render_node(node, context)) > File "C:\Python25\lib\site-packages\django\template\debug.py" in > render_node > 81. raise wrapped > > Exception Type: TemplateSyntaxError at /links/category/1/ > Exception Value: Caught an exception while rendering: Reverse for > 'gpp.gpp.weblinks.views.view_links' with arguments '()' and keyword > arguments '{'category': 1L, 'sort': 'title', 'page': 2, 'dir': 'up'}' > not found. > > Original Traceback (most recent call last): > File "C:\Python25\lib\site-packages\django\template\debug.py", line > 71, in render_node > result = node.render(context) > File "C:\Python25\Lib\site-packages\django\template\defaulttags.py", > line 378, in render > args=args, kwargs=kwargs) > File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py", > line 252, in reverse > *args, **kwargs))) > File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py", > line 241, in reverse > "arguments '%s' not found." % (lookup_view, args, kwargs)) > NoReverseMatch: Reverse for 'gpp.gpp.weblinks.views.view_links' with > arguments '()' and keyword arguments '{'category': 1L, 'sort': > 'title', 'page': 2, 'dir': 'up'}' not found. > > {% if page.has_next %} > <a href="{% url gpp.weblinks.views.view_links > category=category.id,sort=s,dir=d,page=page.next_page_number %}"> > Next Page</a> > {% endif %} > > Thank you. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---