Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing named url patterns throws error in Django 1.4
    primarykey
    data
    text
    <p>I am using named url-patterns in my Django app, but it is failing and I don't know why. I have followed the <a href="https://docs.djangoproject.com/en/1.4/topics/http/urls/#naming-url-patterns" rel="nofollow" title="docs">docs</a> but my app errors out when it reads <strong>urls.py</strong>.</p> <p>This <strong>works</strong>:</p> <p><strong>urls.py</strong></p> <pre><code>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&lt;q_vol&gt;\d+)/no(?P&lt;q_no&gt;\d+)/(?P&lt;q_slug&gt;[^.*]+)/$', detail), (r'^vol(?P&lt;q_vol&gt;\d+)/no(?P&lt;q_no&gt;\d+)/$', index), (r'^vol(?P&lt;q_vol&gt;\d+)/$', index), (r'^$', index), ) </code></pre> <p>But this <strong>fails</strong>:</p> <p><strong>urls.py</strong></p> <pre><code>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&lt;q_vol&gt;\d+)/no(?P&lt;q_no&gt;\d+)/(?P&lt;q_slug&gt;[^.*]+)/$', detail, name='newsletter-detail'), (r'^vol(?P&lt;q_vol&gt;\d+)/no(?P&lt;q_no&gt;\d+)/$', index), (r'^vol(?P&lt;q_vol&gt;\d+)/$', index), (r'^$', index), ) </code></pre> <p>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 <strong>name=""</strong> and it causes the error:</p> <pre class="lang-python prettyprint-override"><code>SyntaxError at /newsletter/ invalid syntax (urls.py, line 6) </code></pre> <p>This urls.py is referenced by the parent urls.py:</p> <pre class="lang-python prettyprint-override"><code>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')), ) </code></pre> <p>I am using Django version 1.4. TIA.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload