diff options
| author | Honza Král <honza.kral@gmail.com> | 2009-09-11 21:23:55 +0000 |
|---|---|---|
| committer | Honza Král <honza.kral@gmail.com> | 2009-09-11 21:23:55 +0000 |
| commit | 9222091de8fa2fcb4fedd74ac99b65c88d295135 (patch) | |
| tree | 32069d6f3f1fce7bc06d257113999f41a0ce31c1 /docs/topics | |
| parent | 78d75b86e3e45ec3ca9f2ace21255922046dd509 (diff) | |
[soc2009/model-validation] Merged to trunk at r11499
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11513 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/auth.txt | 11 | ||||
| -rw-r--r-- | docs/topics/generic-views.txt | 20 |
2 files changed, 17 insertions, 14 deletions
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt index 7858e44962..615382bb07 100644 --- a/docs/topics/auth.txt +++ b/docs/topics/auth.txt @@ -29,13 +29,16 @@ Installation Authentication support is bundled as a Django application in ``django.contrib.auth``. To install it, do the following: - 1. Put ``'django.contrib.auth'`` in your :setting:`INSTALLED_APPS` setting. + 1. Put ``'django.contrib.auth'`` and ``'django.contrib.contenttypes'`` in + your :setting:`INSTALLED_APPS` setting. + (The :class:`~django.contrib.auth.models.Permisson` model in + :mod:`django.contrib.auth` depends on :mod:`django.contrib.contenttypes`.) 2. Run the command ``manage.py syncdb``. Note that the default :file:`settings.py` file created by -:djadmin:`django-admin.py startproject` includes ``'django.contrib.auth'`` in -:setting:`INSTALLED_APPS` for convenience. If your :setting:`INSTALLED_APPS` -already contains ``'django.contrib.auth'``, feel free to run +:djadmin:`django-admin.py startproject` includes ``'django.contrib.auth'`` and +``'django.contrib.contenttypes'`` in :setting:`INSTALLED_APPS` for convenience. +If your :setting:`INSTALLED_APPS` already contains these apps, feel free to run :djadmin:`manage.py syncdb` again; you can run that command as many times as you'd like, and each time it'll only install what's needed. diff --git a/docs/topics/generic-views.txt b/docs/topics/generic-views.txt index c7d751a86b..e4094ac000 100644 --- a/docs/topics/generic-views.txt +++ b/docs/topics/generic-views.txt @@ -150,7 +150,7 @@ be using these models:: publisher = models.ForeignKey(Publisher) publication_date = models.DateField() -To build a list page of all books, we'd use a URLconf along these lines:: +To build a list page of all publishers, we'd use a URLconf along these lines:: from django.conf.urls.defaults import * from django.views.generic import list_detail @@ -176,7 +176,7 @@ version of the model's name. .. highlightlang:: html+django This template will be rendered against a context containing a variable called -``object_list`` that contains all the book objects. A very simple template +``object_list`` that contains all the publisher objects. A very simple template might look like the following:: {% extends "base.html" %} @@ -217,7 +217,7 @@ Making "friendly" template contexts You might have noticed that our sample publisher list template stores all the books in a variable named ``object_list``. While this works just fine, it isn't all that "friendly" to template authors: they have to "just know" that they're -dealing with books here. A better name for that variable would be +dealing with publishers here. A better name for that variable would be ``publisher_list``; that variable's content is pretty obvious. We can change the name of that variable easily with the ``template_object_name`` @@ -241,14 +241,14 @@ Adding extra context -------------------- Often you simply need to present some extra information beyond that provided by -the generic view. For example, think of showing a list of all the other -publishers on each publisher detail page. The ``object_detail`` generic view -provides the publisher to the context, but it seems there's no way to get a list -of *all* publishers in that template. +the generic view. For example, think of showing a list of all the books on each +publisher detail page. The ``object_detail`` generic view provides the +publisher to the context, but it seems there's no way to get additional +information in that template. But there is: all generic views take an extra optional parameter, ``extra_context``. This is a dictionary of extra objects that will be added to -the template's context. So, to provide the list of all publishers on the detail +the template's context. So, to provide the list of all books on the detail detail view, we'd use an info dict like this: .. parsed-literal:: @@ -268,9 +268,9 @@ generic view. It's very handy. However, there's actually a subtle bug here -- can you spot it? The problem has to do with when the queries in ``extra_context`` are evaluated. -Because this example puts ``Publisher.objects.all()`` in the URLconf, it will +Because this example puts ``Book.objects.all()`` in the URLconf, it will be evaluated only once (when the URLconf is first loaded). Once you add or -remove publishers, you'll notice that the generic view doesn't reflect those +remove books, you'll notice that the generic view doesn't reflect those changes until you reload the Web server (see :ref:`caching-and-querysets` for more information about when QuerySets are cached and evaluated). |
