diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2006-05-10 04:39:34 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2006-05-10 04:39:34 +0000 |
| commit | b15b11f5b79a4bfce73e82ea7cdb0b3a0652c9cc (patch) | |
| tree | 5546a35d7a7cbe9c70fbaefb8912d6922905737d /docs/model-api.txt | |
| parent | 4aeb7b02107bdc2842e9e9c82b4f2369cb3ca2bf (diff) | |
multi-auth: Merged to [2890]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2891 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/model-api.txt')
| -rw-r--r-- | docs/model-api.txt | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt index 073a0f3ea9..6d6249ee88 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -52,7 +52,7 @@ Some technical notes: * The name of the table, ``myapp_person``, is automatically derived from some model metadata but can be overridden. See _`Table names` below. * An ``id`` field is added automatically, but this behavior can be - overriden. See _`Automatic primary key fields` below. + overriden. See `Automatic primary key fields`_ below. * The ``CREATE TABLE`` SQL in this example is formatted using PostgreSQL syntax, but it's worth noting Django uses SQL tailored to the database backend specified in your `settings file`_. @@ -124,7 +124,7 @@ Here are all available field types: An ``IntegerField`` that automatically increments according to available IDs. You usually won't need to use this directly; a primary key field will automatically be added to your model if you don't specify otherwise. See -_`Automatic primary key fields`. +`Automatic primary key fields`_. ``BooleanField`` ~~~~~~~~~~~~~~~~ @@ -1111,7 +1111,7 @@ If ``fields`` isn't given, Django will default to displaying each field that isn't an ``AutoField`` and has ``editable=True``, in a single fieldset, in the same order as the fields are defined in the model. -The ``field_options`` dictionary can have the following keys:: +The ``field_options`` dictionary can have the following keys: ``fields`` ~~~~~~~~~~ @@ -1312,6 +1312,8 @@ The way ``Manager`` classes work is documented in the `Retrieving objects`_ section of the database API docs, but this section specifically touches on model options that customize ``Manager`` behavior. +.. _Retrieving objects: http://www.djangoproject.com/documentation/db_api/#retrieving-objects + Manager names ------------- @@ -1401,17 +1403,17 @@ example, using this model:: ...the statement ``Book.objects.all()`` will return all books in the database. -You can override a ``Manager``'s base ``QuerySet`` by overriding the +You can override a ``Manager``\'s base ``QuerySet`` by overriding the ``Manager.get_query_set()`` method. ``get_query_set()`` should return a ``QuerySet`` with the properties you require. -For example, the following model has *two* ``Manager``s -- one that returns +For example, the following model has *two* ``Manager``\s -- one that returns all objects, and one that returns only the books by Roald Dahl:: # First, define the Manager subclass. class DahlBookManager(models.Manager): def get_query_set(self): - return super(Manager, self).get_query_set().filter(author='Roald Dahl') + return super(DahlBookManager, self).get_query_set().filter(author='Roald Dahl') # Then hook it into the Book model explicitly. class Book(models.Model): @@ -1442,11 +1444,11 @@ For example:: class MaleManager(models.Manager): def get_query_set(self): - return super(Manager, self).get_query_set().filter(sex='M') + return super(MaleManager, self).get_query_set().filter(sex='M') class FemaleManager(models.Manager): def get_query_set(self): - return super(Manager, self).get_query_set().filter(sex='F') + return super(FemaleManager, self).get_query_set().filter(sex='F') class Person(models.Model): first_name = models.CharField(maxlength=50) |
