summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial02.txt
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2013-05-19 01:37:25 -0700
committerMarc Tamlyn <marc.tamlyn@gmail.com>2013-05-19 01:37:25 -0700
commit33c361ef9d882522aeae549a3a8c8b52ca5cfc5a (patch)
tree7c07f1f460ea123af7d9aa29ac6de254b423f9cc /docs/intro/tutorial02.txt
parentc70ca4879ee33fc4b70ad9a17d74b649f8f75487 (diff)
parenta4a761ada2286e0f08282efe8dffcd1b384c052c (diff)
Merge pull request #1129 from frog32/master
Add needed Imports to the Documentation
Diffstat (limited to 'docs/intro/tutorial02.txt')
-rw-r--r--docs/intro/tutorial02.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt
index 1987c51a67..dd3e86d8ae 100644
--- a/docs/intro/tutorial02.txt
+++ b/docs/intro/tutorial02.txt
@@ -158,6 +158,9 @@ you want when you register the object.
Let's see how this works by re-ordering the fields on the edit form. Replace
the ``admin.site.register(Poll)`` line with::
+ from django.contrib import admin
+ from polls.models import Poll
+
class PollAdmin(admin.ModelAdmin):
fields = ['pub_date', 'question']
@@ -179,6 +182,9 @@ of fields, choosing an intuitive order is an important usability detail.
And speaking of forms with dozens of fields, you might want to split the form
up into fieldsets::
+ from django.contrib import admin
+ from polls.models import Poll
+
class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
@@ -198,6 +204,9 @@ You can assign arbitrary HTML classes to each fieldset. Django provides a
This is useful when you have a long form that contains a number of fields that
aren't commonly used::
+ from django.contrib import admin
+ from polls.models import Poll
+
class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
@@ -218,6 +227,7 @@ Yet.
There are two ways to solve this problem. The first is to register ``Choice``
with the admin just as we did with ``Poll``. That's easy::
+ from django.contrib import admin
from polls.models import Choice
admin.site.register(Choice)
@@ -342,6 +352,12 @@ representation of the output.
You can improve that by giving that method (in :file:`polls/models.py`) a few
attributes, as follows::
+ import datetime
+ from django.utils import timezone
+ from django.db import models
+
+ from polls.models import Poll
+
class Poll(models.Model):
# ...
def was_published_recently(self):