diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-02 14:51:54 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-02 14:51:54 +0000 |
| commit | 95bcb70b5624a22cfc29795ea363e4a42fce6638 (patch) | |
| tree | 3f3080e84dd04a068616da605a1f55c98a34fe56 | |
| parent | 87d3ff731bfbedaefa8cb762c92df18e5d234978 (diff) | |
Fixed #10367 -- Corrected an example in the documentation for GenericRelation. Thanks to George Song for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | docs/ref/contrib/contenttypes.txt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt index 23188c67e7..05862bc342 100644 --- a/docs/ref/contrib/contenttypes.txt +++ b/docs/ref/contrib/contenttypes.txt @@ -313,7 +313,7 @@ referred to above used fields named ``content_type_fk`` and ``object_primary_key`` to create its generic foreign key, then a ``GenericRelation`` back to it would need to be defined like so:: - tags = generic.GenericRelation('content_type_fk', 'object_primary_key') + tags = generic.GenericRelation(TaggedItem, content_type_field='content_type_fk', object_id_field='object_primary_key') Of course, if you don't add the reverse relationship, you can do the same types of lookups manually:: @@ -324,14 +324,14 @@ same types of lookups manually:: ... object_id=b.id) [<TaggedItem: django>, <TaggedItem: python>] -Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey` -that you're referring to uses a non-default value for ``ct_field`` or ``fk_field`` -(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``), +Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey` +that you're referring to uses a non-default value for ``ct_field`` or ``fk_field`` +(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``), you'll need to pass ``content_type_field`` and ``object_id_field`` to :class:`~django.contrib.contenttypes.generic.GenericRelation`.:: comments = generic.GenericRelation(Comment, content_type_field="content_type", object_id_field="object_pk") - + Note that if you delete an object that has a :class:`~django.contrib.contenttypes.generic.GenericRelation`, any objects which have a :class:`~django.contrib.contenttypes.generic.GenericForeignKey` @@ -342,7 +342,7 @@ it would be deleted at the same time. Generic relations in forms and admin ------------------------------------ -:mod:`django.contrib.contenttypes.generic` provides both a +:mod:`django.contrib.contenttypes.generic` provides both a :class:`~django.contrib.contenttypes.generic.GenericInlineFormSet` and :class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`. This enables the use of generic relations in forms and the admin. See the @@ -361,8 +361,8 @@ This enables the use of generic relations in forms and the admin. See the The name of the :class:`~django.contrib.contenttypes.models.ContentType` foreign key field on the model. Defaults to ``content_type``. - + .. attribute:: generic.GenericInlineModelAdmin.ct_fk_field - + The name of the integer field that represents the ID of the related object. Defaults to ``object_id``. |
