Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:35+00:00 2026-06-10T00:55:35+00:00

I am using named url-patterns in my Django app, but it is failing and

  • 0

I am using named url-patterns in my Django app, but it is failing and I don’t know why. I have followed the docs but my app errors out when it reads urls.py.

This works:

urls.py

from django.conf.urls import patterns
from www.apps.newsletter.models import Newsletter
from www.apps.newsletter.views import index, detail

urlpatterns = patterns('',
    (r'^vol(?P<q_vol>\d+)/no(?P<q_no>\d+)/(?P<q_slug>[^.*]+)/$', detail),
    (r'^vol(?P<q_vol>\d+)/no(?P<q_no>\d+)/$', index),
    (r'^vol(?P<q_vol>\d+)/$', index),
    (r'^$', index),
)

But this fails:

urls.py

from django.conf.urls import patterns
from www.apps.newsletter.models import Newsletter
from www.apps.newsletter.views import index, detail

urlpatterns = patterns('',
    (r'^vol(?P<q_vol>\d+)/no(?P<q_no>\d+)/(?P<q_slug>[^.*]+)/$', detail, name='newsletter-detail'),
    (r'^vol(?P<q_vol>\d+)/no(?P<q_no>\d+)/$', index),
    (r'^vol(?P<q_vol>\d+)/$', index),
    (r'^$', index),
)

I want to use named url patterns (so I can use {% url %} in my template), but Django doesn’t seem to want to play nice. Any ideas? All I am doing is adding the arg name=”” and it causes the error:

SyntaxError at /newsletter/

invalid syntax (urls.py, line 6)

This urls.py is referenced by the parent urls.py:

urlpatterns = patterns('',
    url(r'^grappelli/', include('grappelli.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^software/', include('www.apps.software.urls')),
    url(r'^newsletter/', include('www.apps.newsletter.urls')),
)

I am using Django version 1.4. TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:55:35+00:00Added an answer on June 10, 2026 at 12:55 am

    You need to use the url function to make use of the name parameter:

    url(r'^vol(?P<q_vol>\d+)/no(?P<q_no>\d+)/(?P<q_slug>[^.*]+)/$', detail, name='newsletter-detail'),
    

    In other words, there is a difference between using a tuple and the url function.

    Btw, you don’t need to have named url patterns to make use of the url template tag, you can just use the view’s path instead, i.e. {% url "app.views.myview" %}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this guide to use Django 'out-of-box' with Google App Engine using
Hi I am using following URL patterns in django and I am wondering that
i get : Using the URLconf defined in blog.urls, Django tried these URL patterns,
I have annoying problems using django-sitetree (version 0.5.1) for generating a navigation menu with
Using the Django-auth application (Django version 1.3), I want to have my login page
I'm trying to pass keyword arguments to a Django view using a dictionary, but
I have used django-tastypie using GET,POST,PUT,DELETE methods , they are working smoothly when both
I have a fully functioning Django project (not in a virtualenv) which has url
I followed the installation guide for django-tinymce and Using TinyMCE in Django , installed
I'm new to Django... I have installed a Django external App called Haystack, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.