Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24594 closed Uncategorized (invalid)

urlpatterns as list breaks template code

Reported by: stephanm Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

According to
https://docs.djangoproject.com/en/1.8/releases/1.8/#django-conf-urls-patterns

I switched a working project from

urlpatterns = patterns('',
                       url(r'^$', 'myapp.views.index', name="home"),
)

to

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

LOGIN_URL = "/myapp/auth/login/"

which breaks too.
This one works (at least) if I change it to:

LOGIN_URL = "myapp.views.login"

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

Change History (3)

comment:1 by Tim Graham, 10 years ago

Resolution: worksforme
Status: newclosed

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.

comment:2 by stephanm, 10 years ago

Hi,

It was my mistake, the old code i my project/urls.py
contained:

if settings.DEBUG:
        urlpatterns += staticfiles_urlpatterns()

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

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.

comment:3 by Tim Graham, 10 years ago

Resolution: worksformeinvalid
Note: See TracTickets for help on using tickets.
Back to Top