Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10367 -- Corrected an example in the documentation for Generic…

…Relation. Thanks to George Song for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 95bcb70b5624a22cfc29795ea363e4a42fce6638 1 parent 87d3ff7
Russell Keith-Magee authored May 02, 2009

Showing 1 changed file with 8 additions and 8 deletions. Show diff stats Hide diff stats

  1. 16  docs/ref/contrib/contenttypes.txt
16  docs/ref/contrib/contenttypes.txt
@@ -313,7 +313,7 @@ referred to above used fields named ``content_type_fk`` and
313 313
 ``object_primary_key`` to create its generic foreign key, then a
314 314
 ``GenericRelation`` back to it would need to be defined like so::
315 315
 
316  
-    tags = generic.GenericRelation('content_type_fk', 'object_primary_key')
  316
+    tags = generic.GenericRelation(TaggedItem, content_type_field='content_type_fk', object_id_field='object_primary_key')
317 317
 
318 318
 Of course, if you don't add the reverse relationship, you can do the
319 319
 same types of lookups manually::
@@ -324,14 +324,14 @@ same types of lookups manually::
324 324
     ...                           object_id=b.id)
325 325
     [<TaggedItem: django>, <TaggedItem: python>]
326 326
 
327  
-Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey` 
328  
-that you're referring to uses a non-default value for ``ct_field`` or ``fk_field`` 
329  
-(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``), 
  327
+Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
  328
+that you're referring to uses a non-default value for ``ct_field`` or ``fk_field``
  329
+(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
330 330
 you'll need to pass ``content_type_field`` and ``object_id_field`` to
331 331
 :class:`~django.contrib.contenttypes.generic.GenericRelation`.::
332 332
 
333 333
 	comments = generic.GenericRelation(Comment, content_type_field="content_type", object_id_field="object_pk")
334  
-	
  334
+
335 335
 Note that if you delete an object that has a
336 336
 :class:`~django.contrib.contenttypes.generic.GenericRelation`, any objects
337 337
 which have a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
@@ -342,7 +342,7 @@ it would be deleted at the same time.
342 342
 Generic relations in forms and admin
343 343
 ------------------------------------
344 344
 
345  
-:mod:`django.contrib.contenttypes.generic` provides both a 
  345
+:mod:`django.contrib.contenttypes.generic` provides both a
346 346
 :class:`~django.contrib.contenttypes.generic.GenericInlineFormSet`
347 347
 and :class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`.
348 348
 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
361 361
         The name of the
362 362
         :class:`~django.contrib.contenttypes.models.ContentType` foreign key
363 363
         field on the model. Defaults to ``content_type``.
364  
-    
  364
+
365 365
     .. attribute:: generic.GenericInlineModelAdmin.ct_fk_field
366  
-    
  366
+
367 367
         The name of the integer field that represents the ID of the related
368 368
         object. Defaults to ``object_id``.

0 notes on commit 95bcb70

Please sign in to comment.
Something went wrong with that request. Please try again.