Author: ubernostrum
Date: 2009-03-31 12:14:48 -0500 (Tue, 31 Mar 2009)
New Revision: 10274

Modified:
   django/branches/releases/1.0.X/docs/ref/contrib/contenttypes.txt
Log:
[1.0.X] Fixed #10367: Added note to generic-relation docs explaining when it's 
necessary to pass in field names to create a reverse relation. Backport of 
[10273] from trunk.

Modified: django/branches/releases/1.0.X/docs/ref/contrib/contenttypes.txt
===================================================================
--- django/branches/releases/1.0.X/docs/ref/contrib/contenttypes.txt    
2009-03-31 17:14:10 UTC (rev 10273)
+++ django/branches/releases/1.0.X/docs/ref/contrib/contenttypes.txt    
2009-03-31 17:14:48 UTC (rev 10274)
@@ -303,8 +303,21 @@
     >>> 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)
     >>> TaggedItem.objects.filter(content_type__pk=bookmark_type.id,


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to