summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJames Bennett <ubernostrum@gmail.com>2009-03-31 17:14:10 +0000
committerJames Bennett <ubernostrum@gmail.com>2009-03-31 17:14:10 +0000
commit131de1cf2b91dd5743d8994b3b0efea3639de7db (patch)
tree1898515245d78b87bcee3c037249ef13f056d1cb /docs
parentaea0bb68e05e57beb1690b39b4ce5da424f50a4c (diff)
Fixed #10367: Added note to generic-relation docs explaining when it's necessary to pass in field names to create a reverse relation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/contenttypes.txt15
1 files changed, 14 insertions, 1 deletions
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index 2a1c831408..42a8a8142b 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -303,7 +303,20 @@ be used to retrieve their associated ``TaggedItems``::
>>> b.tags.all()
[<TaggedItem: django>, <TaggedItem: python>]
-If you don't add the reverse relationship, you can do the lookup manually::
+Just as :class:`django.contrib.contenttypes.generic.GenericForeignKey`
+accepts the names of the content-type and object-ID fields as
+arguments, so too does ``GenericRelation``; if the model which has the
+generic foreign key is using non-default names for those fields, you
+must pass the names of the fields when setting up a
+``GenericRelation`` to it. For example, if the ``TaggedItem`` model
+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')
+
+Of course, if you don't add the reverse relationship, you can do the
+same types of lookups manually::
>>> b = Bookmark.objects.get(url='http://www.djangoproject.com/')
>>> bookmark_type = ContentType.objects.get_for_model(b)