[Django] #24594: urlpatterns as list breaks template code

12 views
Skip to first unread message

Django

unread,
Apr 7, 2015, 6:49:18 AM4/7/15
to django-...@googlegroups.com
#24594: urlpatterns as list breaks template code
-------------------------------+--------------------
Reporter: stephanm | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
According to
https://docs.djangoproject.com/en/1.8/releases/1.8/#django-conf-urls-
patterns

I switched a working project from
{{{#!py
urlpatterns = patterns('',
url(r'^$', 'myapp.views.index', name="home"),
)
}}}
to
{{{#!py
urlpatterns = [ url(r'^$', myapp.views.index, name="home"), ]
}}}

But now I get the exception:
{{{
Exception Type: AttributeError
Exception Value:

'list' object has no attribute 'regex'

Exception Location: D:\Programme\python27\lib\site-
packages\django\core\urlresolvers.py in _populate, line 298
}}}

Because I have the following code snippet in my html template:
{{{
{% url 'home' %}
}}}
----
'''Another item:''' In my settings.py I have
{{{#!py
LOGIN_URL = "/myapp/auth/login/"
}}}
which breaks too.
This one works (at least) if I change it to:
{{{#!py
LOGIN_URL = "myapp.views.login"
}}}

System: I use python 2.7.9 (32 bit) on Windows 7 64 bit.

--
Ticket URL: <https://code.djangoproject.com/ticket/24594>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 7, 2015, 7:50:39 AM4/7/15
to django-...@googlegroups.com
#24594: urlpatterns as list breaks template code
-------------------------------+--------------------------------------
Reporter: stephanm | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

We will need more specific details about how to reproduce the error (such
as a minimal project we can download). Please include only one "issue" per
ticket as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/24594#comment:1>

Django

unread,
Apr 7, 2015, 10:09:07 AM4/7/15
to django-...@googlegroups.com
#24594: urlpatterns as list breaks template code
-------------------------------+--------------------------------------
Reporter: stephanm | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by stephanm):

Hi,

It was my mistake, the old code i my project/urls.py
contained:
{{{#!py
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
}}}

and switching to the list form I changed the code to the '''wrong''' form:

{{{#!py
if settings.DEBUG:
urlpatterns.append( staticfiles_urlpatterns() ) #THIS IS WRONG
}}}

I didn't realize that the old code was still OK because
{{{staticfiles_urlpatterns()}}}
returns a {{{list}}}.

--
Ticket URL: <https://code.djangoproject.com/ticket/24594#comment:2>

Django

unread,
Apr 7, 2015, 10:52:14 AM4/7/15
to django-...@googlegroups.com
#24594: urlpatterns as list breaks template code
-------------------------------+--------------------------------------
Reporter: stephanm | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* resolution: worksforme => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/24594#comment:3>

Reply all
Reply to author
Forward
0 new messages