[Django]-New url format in Django 1.9

26👍

Import your views directly, or your views modules:

from apps.views import about
from accounts import views as account_views

Do not use patterns at all, just use a list or tuple:

urlpatterns = [
    url(r'^about/$', about,
        name='about'),
]

urlpatterns += [
    url(r'^signin/$', account_views.auth_login,
        name='login'),
]

4👍

You should remove the quotes around views name.
So your code will be like that

urlpatterns = patterns('',
    url(r'^about/$', app.views.about, #without quote!
        name='about'),
)

Point 2, use lists, so your code will transform to

urlpatterns = [
        url(r'^about/$', app.views.about, #without quote!
            name='about'),
    ]

Leave a comment