Last active
June 25, 2016 10:09
-
-
Save santoshpy/298994c3505df2f2fcaaf6b3251d466a to your computer and use it in GitHub Desktop.
Django Project Urls.py Patterns Examples In Django, the matching regex group(s) (ie ?P<month>, ?P<id>, ?P<username>) will be passed as a Keyword Argument (**kwarg) to the matching view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#urls.py | |
""" | |
Django 1.9+ Pattern Syntax | |
""" | |
from blog.views import ( | |
ArticleView, | |
YearArchiveView, | |
MonthArchiveView, | |
PostSlugView, | |
PostIdView, | |
function_based_view, | |
) | |
from orders.views import ( | |
OrderView, | |
UserOrderView, | |
) | |
from profiles.views import ( | |
ProfileView, | |
) | |
urlpatterns = [ | |
url(r'^about/$', function_based_view), | |
url(r'^article/(?P<slug>[\w-]+)/$', ArticleView.as_view()), | |
url(r'^blog/(?P<year>\d{4})/$', YearArchiveView.as_view()), | |
url(r'^blog/(?P<year>\d{4})/(?P<month>\d{2})/$', YearArchiveView.as_view()), | |
url(r"^order/(?P<order>\d+)/$", OrderView.as_view()), | |
url(r"^order/(?P<username>[\w.@+-]+)/(?P<order>\d+)/$", UserOrderView.as_view()), | |
url(r'^profile/(?P<username>[\w.@+-]+)/$', ProfileView.as_view()), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment