Advertisement
Guest User

url.py

a guest
Jul 12th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. from django.conf.urls import url
  2. from django.contrib import admin
  3. from django.views.generic import TemplateView
  4. from collection import views
  5.  
  6. urlpatterns = [
  7. # url() encases the entry to indicate it's url entry
  8. # r'^$' is the beginning of the URL pattern
  9. # views.index means that we'll use the index view in views
  10. # name='home' is optional but allows us to assign a name to this url so we
  11. # can refer to it in the future as 'home'
  12. # Another way to layout the url is:
  13. # url(
  14. # regex=r'^$',
  15. # view=views.index,
  16. # name='home'
  17. # )
  18. url(r'^$', views.index, name='home'),
  19. url(r'^about/$',
  20. TemplateView.as_view(template_name='about.html'),
  21. name='about'),
  22. url(r'^contact/$',
  23. TemplateView.as_view(template_name='contact.html'),
  24. name='contact'),
  25. #r'^questions/: "starts with questions"
  26. #(?P<slug>[-\w]+)/$: "matches any word and call it 'slug' and 'slug' can be
  27. # changed for other uses
  28. # 'collection.views.question_detail': We are using the soon to be created
  29. # thing_detail view
  30. # , name='question_detail': This URL is named question_detail
  31. url(r'^questions/(?P<slug>[-\w]+)/$', views.question_detail,
  32. name='questions_detail'),
  33. url(r'^questions/(?P<slug>[-\w]+)/edit/$',
  34. views.edit_question, name='edit_question'),
  35. url(r'^admin/', admin.site.urls),
  36. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement