Loading docs/intro/tutorial02.txt +12 −6 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ file, and edit it to look like this: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question admin.site.register(Question) Loading Loading @@ -193,7 +194,8 @@ the ``admin.site.register(Question)`` line with: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading Loading @@ -221,7 +223,8 @@ up into fieldsets: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading @@ -248,7 +251,8 @@ aren't commonly used: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading Loading @@ -277,7 +281,8 @@ with the admin just as we did with ``Question``. That's easy: :filename: polls/admin.py from django.contrib import admin from polls.models import Choice, Question from .models import Choice, Question # ... admin.site.register(Choice) Loading Loading @@ -310,7 +315,8 @@ registration code to read: :filename: polls/admin.py from django.contrib import admin from polls.models import Choice, Question from .models import Choice, Question class ChoiceInline(admin.StackedInline): Loading docs/intro/tutorial03.txt +7 −7 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ In the ``polls/urls.py`` file include the following code: from django.conf.urls import url from polls import views from . import views urlpatterns = [ url(r'^$', views.index, name='index'), Loading Loading @@ -209,7 +209,7 @@ Wire these new views into the ``polls.urls`` module by adding the following from django.conf.urls import url from polls import views from . import views urlpatterns = [ # ex: /polls/ Loading Loading @@ -296,7 +296,7 @@ commas, according to publication date: from django.http import HttpResponse from polls.models import Question from .models import Question def index(request): Loading Loading @@ -374,7 +374,7 @@ Now let's update our ``index`` view in ``polls/views.py`` to use the template: from django.http import HttpResponse from django.template import RequestContext, loader from polls.models import Question from .models import Question def index(request): Loading Loading @@ -406,7 +406,7 @@ rewritten: from django.shortcuts import render from polls.models import Question from .models import Question def index(request): Loading Loading @@ -436,7 +436,7 @@ for a given poll. Here's the view: from django.http import Http404 from django.shortcuts import render from polls.models import Question from .models import Question # ... def detail(request, question_id): try: Loading Loading @@ -471,7 +471,7 @@ provides a shortcut. Here's the ``detail()`` view, rewritten: from django.shortcuts import get_object_or_404, render from polls.models import Question from .models import Question # ... def detail(request, question_id): question = get_object_or_404(Question, pk=question_id) Loading docs/intro/tutorial04.txt +3 −3 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ create a real version. Add the following to ``polls/views.py``: from django.http import HttpResponseRedirect, HttpResponse from django.core.urlresolvers import reverse from polls.models import Choice, Question from .models import Choice, Question # ... def vote(request, question_id): p = get_object_or_404(Question, pk=question_id) Loading Loading @@ -225,7 +225,7 @@ First, open the ``polls/urls.py`` URLconf and change it like so: from django.conf.urls import url from polls import views from . import views urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), Loading Loading @@ -254,7 +254,7 @@ views and use Django's generic views instead. To do so, open the from django.core.urlresolvers import reverse from django.views import generic from polls.models import Choice, Question from .models import Choice, Question class IndexView(generic.ListView): Loading docs/intro/tutorial05.txt +2 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,8 @@ Put the following in the ``tests.py`` file in the ``polls`` application: from django.utils import timezone from django.test import TestCase from polls.models import Question from .models import Question class QuestionMethodTests(TestCase): Loading Loading
docs/intro/tutorial02.txt +12 −6 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ file, and edit it to look like this: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question admin.site.register(Question) Loading Loading @@ -193,7 +194,8 @@ the ``admin.site.register(Question)`` line with: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading Loading @@ -221,7 +223,8 @@ up into fieldsets: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading @@ -248,7 +251,8 @@ aren't commonly used: :filename: polls/admin.py from django.contrib import admin from polls.models import Question from .models import Question class QuestionAdmin(admin.ModelAdmin): Loading Loading @@ -277,7 +281,8 @@ with the admin just as we did with ``Question``. That's easy: :filename: polls/admin.py from django.contrib import admin from polls.models import Choice, Question from .models import Choice, Question # ... admin.site.register(Choice) Loading Loading @@ -310,7 +315,8 @@ registration code to read: :filename: polls/admin.py from django.contrib import admin from polls.models import Choice, Question from .models import Choice, Question class ChoiceInline(admin.StackedInline): Loading
docs/intro/tutorial03.txt +7 −7 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ In the ``polls/urls.py`` file include the following code: from django.conf.urls import url from polls import views from . import views urlpatterns = [ url(r'^$', views.index, name='index'), Loading Loading @@ -209,7 +209,7 @@ Wire these new views into the ``polls.urls`` module by adding the following from django.conf.urls import url from polls import views from . import views urlpatterns = [ # ex: /polls/ Loading Loading @@ -296,7 +296,7 @@ commas, according to publication date: from django.http import HttpResponse from polls.models import Question from .models import Question def index(request): Loading Loading @@ -374,7 +374,7 @@ Now let's update our ``index`` view in ``polls/views.py`` to use the template: from django.http import HttpResponse from django.template import RequestContext, loader from polls.models import Question from .models import Question def index(request): Loading Loading @@ -406,7 +406,7 @@ rewritten: from django.shortcuts import render from polls.models import Question from .models import Question def index(request): Loading Loading @@ -436,7 +436,7 @@ for a given poll. Here's the view: from django.http import Http404 from django.shortcuts import render from polls.models import Question from .models import Question # ... def detail(request, question_id): try: Loading Loading @@ -471,7 +471,7 @@ provides a shortcut. Here's the ``detail()`` view, rewritten: from django.shortcuts import get_object_or_404, render from polls.models import Question from .models import Question # ... def detail(request, question_id): question = get_object_or_404(Question, pk=question_id) Loading
docs/intro/tutorial04.txt +3 −3 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ create a real version. Add the following to ``polls/views.py``: from django.http import HttpResponseRedirect, HttpResponse from django.core.urlresolvers import reverse from polls.models import Choice, Question from .models import Choice, Question # ... def vote(request, question_id): p = get_object_or_404(Question, pk=question_id) Loading Loading @@ -225,7 +225,7 @@ First, open the ``polls/urls.py`` URLconf and change it like so: from django.conf.urls import url from polls import views from . import views urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), Loading Loading @@ -254,7 +254,7 @@ views and use Django's generic views instead. To do so, open the from django.core.urlresolvers import reverse from django.views import generic from polls.models import Choice, Question from .models import Choice, Question class IndexView(generic.ListView): Loading
docs/intro/tutorial05.txt +2 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,8 @@ Put the following in the ``tests.py`` file in the ``polls`` application: from django.utils import timezone from django.test import TestCase from polls.models import Question from .models import Question class QuestionMethodTests(TestCase): Loading