GenericRelation counterpart of GenericForeignKey requires repeation

6 views
Skip to first unread message

webograph

unread,
Apr 11, 2007, 1:25:29 PM4/11/07
to django-d...@googlegroups.com
hi,

when setting up a GenericForeignKey with non-standard ct_field and
fk_field, you need to specify those fields at the corresponding
GenericRelation as content_type_field and object_id_field again; this
does not feel quite correct (speak: DRY), but i don't know enough about
the way relation counterparts work to fix it.

an example:

class A(models.Model):
myB =
models.GenericRelation('A',object_id_field='details_id',content_type_field='details_ct')
class B(models.Model):
...
details =
models.GenericForeignKey(ct_field='details_ct',fk_field='details_id')

the problem becomes first apparent when delete()ing an A type object.

is this a valid bug or the way it has to be due to the (to me)
mysterious nature of GenericForeignKey-s?

regards
webograph

Reply all
Reply to author
Forward
0 new messages