Reputation: 6795
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r"^$", home),
url(r"^storefront/", storefront),
url(r"^sell/", get_entry),
.
ImportError: cannot import name patterns
The above is a snippet of my urls.py, is fixing this just a matter of changing my import statement or will I literally need to rewrite my entire urls.py now that the patterns module has been deprecated?
Upvotes: 0
Views: 1026
Reputation: 1756
In django 1.10 the urls can be defined in the following way:-
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
urlpatterns = i18n_patterns(
url("^admin/", include(admin.site.urls)),
)
if settings.USE_MODELTRANSLATION:
urlpatterns += [
url('^i18n/$', set_language, name='set_language'),
]
urlpatterns += [
url("^", include("your_app.urls")),
]
So you dont have to change all your urls. Just place correctly i.e if you are useing I18N place them with admin in urlpatterns = i18n_patterns section else in another section as in example above replace the name with your_app.urls.
Upvotes: 2