Reputation: 123
urls.py file which is in 1.1 version of Django :-
urlpatterns = patterns('ecomstore.catalog.views',
(r'^category/(?P<category_slug>[-\w]+)/$','show_category',
{'template_name':'catalog/category.html'},'catalog_category'),
)
which I understood that first argument id prefix to all views. next argument is url which has four argument one is url string(regex),second is view , third is dict passing template name and fourth is location of category.
How to write it in Django 1.10 is following it correct way:-
from django.conf.urls import url
from ecommstore.catalog.views import *
urlpatterns = [
url(r'^category/(?P<category_slug>[-\w]+)/$','show_category',
{'template_name':'catalog/category.html'},'catalog_category'),
]
Upvotes: 0
Views: 334
Reputation: 53699
You're almost there. You've imported the view, but you're still passing in a string as the view instead of the view function itself:
urlpatterns = [
url(r'^category/(?P<category_slug>[-\w]+)/$', show_category,
{'template_name':'catalog/category.html'}, 'catalog_category'),
]
Upvotes: 1