Friday, October 24, 2014

New way to use URL dispatchers?

Hi,
in the docs, i only see the 'list' way, so why Django 1.7 dont generate the url by the new way and still use the old way?
because i found:

Deprecated since version 1.8: urlpatterns should be a plain list of django.conf.urls.url() instances instead.

source: https://docs.djangoproject.com/en/dev/ref/urls/#patterns

as the example here:
from django.conf.urls import url    from . import views    urlpatterns = [      url(r'^articles/2003/$', views.special_case_2003),      url(r'^articles/([0-9]{4})/$', views.year_archive),      url(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),      url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),  ]
so the urls.py should be like:

from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = [
    # Examples:
    # url(r'^$', 'First.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/253da748-e5a3-45f3-8195-bbd08754e844%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment