/tests/regressiontests/generic_views/urls.py

https://github.com/liaowang11/django · Python · 205 lines · 169 code · 19 blank · 17 comment · 0 complexity · b8d5bbf8484191b91b54747d3f0db309 MD5 · raw file

  1. from django.conf.urls.defaults import *
  2. from django.views.generic import TemplateView
  3. from django.views.decorators.cache import cache_page
  4. import views
  5. urlpatterns = patterns('',
  6. # base
  7. #(r'^about/login-required/$',
  8. # views.DecoratedAboutView()),
  9. # TemplateView
  10. (r'^template/simple/(?P<foo>\w+)/$',
  11. TemplateView.as_view(template_name='generic_views/about.html')),
  12. (r'^template/custom/(?P<foo>\w+)/$',
  13. views.CustomTemplateView.as_view(template_name='generic_views/about.html')),
  14. (r'^template/cached/(?P<foo>\w+)/$',
  15. cache_page(2.0)(TemplateView.as_view(template_name='generic_views/about.html'))),
  16. # DetailView
  17. (r'^detail/obj/$',
  18. views.ObjectDetail.as_view()),
  19. url(r'^detail/artist/(?P<pk>\d+)/$',
  20. views.ArtistDetail.as_view(),
  21. name="artist_detail"),
  22. url(r'^detail/author/(?P<pk>\d+)/$',
  23. views.AuthorDetail.as_view(),
  24. name="author_detail"),
  25. (r'^detail/author/byslug/(?P<slug>[\w-]+)/$',
  26. views.AuthorDetail.as_view()),
  27. (r'^detail/author/(?P<pk>\d+)/template_name_suffix/$',
  28. views.AuthorDetail.as_view(template_name_suffix='_view')),
  29. (r'^detail/author/(?P<pk>\d+)/template_name/$',
  30. views.AuthorDetail.as_view(template_name='generic_views/about.html')),
  31. (r'^detail/author/(?P<pk>\d+)/context_object_name/$',
  32. views.AuthorDetail.as_view(context_object_name='thingy')),
  33. (r'^detail/author/(?P<pk>\d+)/dupe_context_object_name/$',
  34. views.AuthorDetail.as_view(context_object_name='object')),
  35. (r'^detail/page/(?P<pk>\d+)/field/$',
  36. views.PageDetail.as_view()),
  37. (r'^detail/author/invalid/url/$',
  38. views.AuthorDetail.as_view()),
  39. (r'^detail/author/invalid/qs/$',
  40. views.AuthorDetail.as_view(queryset=None)),
  41. # Create/UpdateView
  42. (r'^edit/artists/create/$',
  43. views.ArtistCreate.as_view()),
  44. (r'^edit/artists/(?P<pk>\d+)/update/$',
  45. views.ArtistUpdate.as_view()),
  46. (r'^edit/authors/create/naive/$',
  47. views.NaiveAuthorCreate.as_view()),
  48. (r'^edit/authors/create/redirect/$',
  49. views.NaiveAuthorCreate.as_view(success_url='/edit/authors/create/')),
  50. (r'^edit/authors/create/interpolate_redirect/$',
  51. views.NaiveAuthorCreate.as_view(success_url='/edit/author/%(id)d/update/')),
  52. (r'^edit/authors/create/restricted/$',
  53. views.AuthorCreateRestricted.as_view()),
  54. (r'^edit/authors/create/$',
  55. views.AuthorCreate.as_view()),
  56. (r'^edit/authors/create/special/$',
  57. views.SpecializedAuthorCreate.as_view()),
  58. (r'^edit/author/(?P<pk>\d+)/update/naive/$',
  59. views.NaiveAuthorUpdate.as_view()),
  60. (r'^edit/author/(?P<pk>\d+)/update/redirect/$',
  61. views.NaiveAuthorUpdate.as_view(success_url='/edit/authors/create/')),
  62. (r'^edit/author/(?P<pk>\d+)/update/interpolate_redirect/$',
  63. views.NaiveAuthorUpdate.as_view(success_url='/edit/author/%(id)d/update/')),
  64. (r'^edit/author/(?P<pk>\d+)/update/$',
  65. views.AuthorUpdate.as_view()),
  66. (r'^edit/author/(?P<pk>\d+)/update/special/$',
  67. views.SpecializedAuthorUpdate.as_view()),
  68. (r'^edit/author/(?P<pk>\d+)/delete/naive/$',
  69. views.NaiveAuthorDelete.as_view()),
  70. (r'^edit/author/(?P<pk>\d+)/delete/redirect/$',
  71. views.NaiveAuthorDelete.as_view(success_url='/edit/authors/create/')),
  72. (r'^edit/author/(?P<pk>\d+)/delete/$',
  73. views.AuthorDelete.as_view()),
  74. (r'^edit/author/(?P<pk>\d+)/delete/special/$',
  75. views.SpecializedAuthorDelete.as_view()),
  76. # ArchiveIndexView
  77. (r'^dates/books/$',
  78. views.BookArchive.as_view()),
  79. (r'^dates/books/context_object_name/$',
  80. views.BookArchive.as_view(context_object_name='thingies')),
  81. (r'^dates/books/allow_empty/$',
  82. views.BookArchive.as_view(allow_empty=True)),
  83. (r'^dates/books/template_name/$',
  84. views.BookArchive.as_view(template_name='generic_views/list.html')),
  85. (r'^dates/books/template_name_suffix/$',
  86. views.BookArchive.as_view(template_name_suffix='_detail')),
  87. (r'^dates/books/invalid/$',
  88. views.BookArchive.as_view(queryset=None)),
  89. (r'^dates/books/paginated/$',
  90. views.BookArchive.as_view(paginate_by=10)),
  91. # ListView
  92. (r'^list/dict/$',
  93. views.DictList.as_view()),
  94. (r'^list/dict/paginated/$',
  95. views.DictList.as_view(paginate_by=1)),
  96. url(r'^list/artists/$',
  97. views.ArtistList.as_view(),
  98. name="artists_list"),
  99. url(r'^list/authors/$',
  100. views.AuthorList.as_view(),
  101. name="authors_list"),
  102. (r'^list/authors/paginated/$',
  103. views.AuthorList.as_view(paginate_by=30)),
  104. (r'^list/authors/paginated/(?P<page>\d+)/$',
  105. views.AuthorList.as_view(paginate_by=30)),
  106. (r'^list/authors/notempty/$',
  107. views.AuthorList.as_view(allow_empty=False)),
  108. (r'^list/authors/template_name/$',
  109. views.AuthorList.as_view(template_name='generic_views/list.html')),
  110. (r'^list/authors/template_name_suffix/$',
  111. views.AuthorList.as_view(template_name_suffix='_objects')),
  112. (r'^list/authors/context_object_name/$',
  113. views.AuthorList.as_view(context_object_name='author_list')),
  114. (r'^list/authors/dupe_context_object_name/$',
  115. views.AuthorList.as_view(context_object_name='object_list')),
  116. (r'^list/authors/invalid/$',
  117. views.AuthorList.as_view(queryset=None)),
  118. (r'^list/authors/paginated/custom_class/$',
  119. views.AuthorList.as_view(paginate_by=5, paginator_class=views.CustomPaginator)),
  120. (r'^list/authors/paginated/custom_constructor/$',
  121. views.AuthorListCustomPaginator.as_view()),
  122. # YearArchiveView
  123. # Mixing keyword and possitional captures below is intentional; the views
  124. # ought to be able to accept either.
  125. (r'^dates/books/(?P<year>\d{4})/$',
  126. views.BookYearArchive.as_view()),
  127. (r'^dates/books/(?P<year>\d{4})/make_object_list/$',
  128. views.BookYearArchive.as_view(make_object_list=True)),
  129. (r'^dates/books/(?P<year>\d{4})/allow_empty/$',
  130. views.BookYearArchive.as_view(allow_empty=True)),
  131. (r'^dates/books/(?P<year>\d{4})/allow_future/$',
  132. views.BookYearArchive.as_view(allow_future=True)),
  133. (r'^dates/books/no_year/$',
  134. views.BookYearArchive.as_view()),
  135. # MonthArchiveView
  136. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
  137. views.BookMonthArchive.as_view()),
  138. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
  139. views.BookMonthArchive.as_view(month_format='%m')),
  140. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_empty/$',
  141. views.BookMonthArchive.as_view(allow_empty=True)),
  142. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/allow_future/$',
  143. views.BookMonthArchive.as_view(allow_future=True)),
  144. (r'^dates/books/(?P<year>\d{4})/no_month/$',
  145. views.BookMonthArchive.as_view()),
  146. # WeekArchiveView
  147. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/$',
  148. views.BookWeekArchive.as_view()),
  149. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_empty/$',
  150. views.BookWeekArchive.as_view(allow_empty=True)),
  151. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/allow_future/$',
  152. views.BookWeekArchive.as_view(allow_future=True)),
  153. (r'^dates/books/(?P<year>\d{4})/week/no_week/$',
  154. views.BookWeekArchive.as_view()),
  155. (r'^dates/books/(?P<year>\d{4})/week/(?P<week>\d{1,2})/monday/$',
  156. views.BookWeekArchive.as_view(week_format='%W')),
  157. # DayArchiveView
  158. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/$',
  159. views.BookDayArchive.as_view()),
  160. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
  161. views.BookDayArchive.as_view(month_format='%m')),
  162. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_empty/$',
  163. views.BookDayArchive.as_view(allow_empty=True)),
  164. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/allow_future/$',
  165. views.BookDayArchive.as_view(allow_future=True)),
  166. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/no_day/$',
  167. views.BookDayArchive.as_view()),
  168. # TodayArchiveView
  169. (r'dates/books/today/$',
  170. views.BookTodayArchive.as_view()),
  171. (r'dates/books/today/allow_empty/$',
  172. views.BookTodayArchive.as_view(allow_empty=True)),
  173. # DateDetailView
  174. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  175. views.BookDetail.as_view()),
  176. (r'^dates/books/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<pk>\d+)/$',
  177. views.BookDetail.as_view(month_format='%m')),
  178. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/allow_future/$',
  179. views.BookDetail.as_view(allow_future=True)),
  180. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/nopk/$',
  181. views.BookDetail.as_view()),
  182. (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/byslug/(?P<slug>[\w-]+)/$',
  183. views.BookDetail.as_view()),
  184. # Useful for testing redirects
  185. (r'^accounts/login/$', 'django.contrib.auth.views.login')
  186. )