diff options
Diffstat (limited to 'docs/ref/class-based-views')
| -rw-r--r-- | docs/ref/class-based-views/base.txt | 19 | ||||
| -rw-r--r-- | docs/ref/class-based-views/generic-date-based.txt | 42 | ||||
| -rw-r--r-- | docs/ref/class-based-views/generic-display.txt | 12 | ||||
| -rw-r--r-- | docs/ref/class-based-views/index.txt | 6 |
4 files changed, 39 insertions, 40 deletions
diff --git a/docs/ref/class-based-views/base.txt b/docs/ref/class-based-views/base.txt index fb98f9d80e..e8f5271e97 100644 --- a/docs/ref/class-based-views/base.txt +++ b/docs/ref/class-based-views/base.txt @@ -39,13 +39,13 @@ View **Example urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import MyView - urlpatterns = patterns('', + urlpatterns = [ url(r'^mine/$', MyView.as_view(), name='my-view'), - ) + ] **Attributes** @@ -131,13 +131,13 @@ TemplateView **Example urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import HomePageView - urlpatterns = patterns('', + urlpatterns = [ url(r'^$', HomePageView.as_view(), name='home'), - ) + ] **Context** @@ -192,17 +192,16 @@ RedirectView **Example urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from django.views.generic.base import RedirectView from article.views import ArticleCounterRedirectView, ArticleDetail - urlpatterns = patterns('', - + urlpatterns = [ url(r'^counter/(?P<pk>\d+)/$', ArticleCounterRedirectView.as_view(), name='article-counter'), url(r'^details/(?P<pk>\d+)/$', ArticleDetail.as_view(), name='article-detail'), url(r'^go-to-django/$', RedirectView.as_view(url='http://djangoproject.com'), name='go-to-django'), - ) + ] **Attributes** diff --git a/docs/ref/class-based-views/generic-date-based.txt b/docs/ref/class-based-views/generic-date-based.txt index bf70f2313b..9d6d447052 100644 --- a/docs/ref/class-based-views/generic-date-based.txt +++ b/docs/ref/class-based-views/generic-date-based.txt @@ -65,16 +65,16 @@ ArchiveIndexView **Example myapp/views.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from django.views.generic.dates import ArchiveIndexView from myapp.models import Article - urlpatterns = patterns('', + urlpatterns = [ url(r'^archive/$', ArchiveIndexView.as_view(model=Article, date_field="pub_date"), name="article_archive"), - ) + ] **Example myapp/article_archive.html**: @@ -166,15 +166,15 @@ YearArchiveView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import ArticleYearArchiveView - urlpatterns = patterns('', + urlpatterns = [ url(r'^(?P<year>\d{4})/$', ArticleYearArchiveView.as_view(), name="article_year_archive"), - ) + ] **Example myapp/article_archive_year.html**: @@ -261,11 +261,11 @@ MonthArchiveView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import ArticleMonthArchiveView - urlpatterns = patterns('', + urlpatterns = [ # Example: /2012/aug/ url(r'^(?P<year>\d{4})/(?P<month>[-\w]+)/$', ArticleMonthArchiveView.as_view(), @@ -274,7 +274,7 @@ MonthArchiveView url(r'^(?P<year>\d{4})/(?P<month>\d+)/$', ArticleMonthArchiveView.as_view(month_format='%m'), name="archive_month_numeric"), - ) + ] **Example myapp/article_archive_month.html**: @@ -355,16 +355,16 @@ WeekArchiveView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import ArticleWeekArchiveView - urlpatterns = patterns('', + urlpatterns = [ # Example: /2012/week/23/ url(r'^(?P<year>\d{4})/week/(?P<week>\d+)/$', ArticleWeekArchiveView.as_view(), name="archive_week"), - ) + ] **Example myapp/article_archive_week.html**: @@ -469,16 +469,16 @@ DayArchiveView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import ArticleDayArchiveView - urlpatterns = patterns('', + urlpatterns = [ # Example: /2012/nov/10/ url(r'^(?P<year>\d{4})/(?P<month>[-\w]+)/(?P<day>\d+)/$', ArticleDayArchiveView.as_view(), name="archive_day"), - ) + ] **Example myapp/article_archive_day.html**: @@ -543,15 +543,15 @@ TodayArchiveView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from myapp.views import ArticleTodayArchiveView - urlpatterns = patterns('', + urlpatterns = [ url(r'^today/$', ArticleTodayArchiveView.as_view(), name="archive_today"), - ) + ] .. admonition:: Where is the example template for ``TodayArchiveView``? @@ -593,14 +593,14 @@ DateDetailView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from django.views.generic.dates import DateDetailView - urlpatterns = patterns('', + urlpatterns = [ url(r'^(?P<year>\d+)/(?P<month>[-\w]+)/(?P<day>\d+)/(?P<pk>\d+)/$', DateDetailView.as_view(model=Article, date_field="pub_date"), name="archive_date_detail"), - ) + ] **Example myapp/article_detail.html**: diff --git a/docs/ref/class-based-views/generic-display.txt b/docs/ref/class-based-views/generic-display.txt index 24006d48d3..1ca8125501 100644 --- a/docs/ref/class-based-views/generic-display.txt +++ b/docs/ref/class-based-views/generic-display.txt @@ -54,13 +54,13 @@ DetailView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from article.views import ArticleDetailView - urlpatterns = patterns('', + urlpatterns = [ url(r'^(?P<slug>[-_\w]+)/$', ArticleDetailView.as_view(), name='article-detail'), - ) + ] **Example myapp/article_detail.html**: @@ -123,13 +123,13 @@ ListView **Example myapp/urls.py**:: - from django.conf.urls import patterns, url + from django.conf.urls import url from article.views import ArticleListView - urlpatterns = patterns('', + urlpatterns = [ url(r'^$', ArticleListView.as_view(), name='article-list'), - ) + ] **Example myapp/article_list.html**: diff --git a/docs/ref/class-based-views/index.txt b/docs/ref/class-based-views/index.txt index 821edc0874..81d5c560f9 100644 --- a/docs/ref/class-based-views/index.txt +++ b/docs/ref/class-based-views/index.txt @@ -25,9 +25,9 @@ a thread-safe operation). A class-based view is deployed into a URL pattern using the :meth:`~django.views.generic.base.View.as_view()` classmethod:: - urlpatterns = patterns('', - (r'^view/$', MyView.as_view(size=42)), - ) + urlpatterns = [ + url(r'^view/$', MyView.as_view(size=42)), + ] .. admonition:: Thread safety with view arguments |
