Hi,
I have been a Django user for a long time now but only recently ran
into
a position where have needed to use Generic relationships, I need to
be
able to do something similar to filtering on a GenericForeignKey.
Essentially I have a media management app that looks something similar
to the following:
class MediaProxy(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
class Media(models.Model):
title = models.CharField(max_length=160)
uploader = models.ForeignKey('auth.User')
proxy = generic.GenericRelation(MediaProxy)
class Meta:
abstract = True
class Image(Media):
content = models.ImageField(upload_to='media/')
The idea being that no matter how many different types of media I have
(images, video, audio, etc..), I can still have them all grouped
together via the MediaProxy model. Although there's a problem in that
you can't filter on the GenericForeignKey attribute because it doesn't
exist in the table.
So I am wondering if anyone knows any way of filtering over multiple
models that inherit from one parent model (and thus are similar)
without
specifically having to run a filter on each model individually as that
would violate DRY and make it a large pain to add new media types.
Any help would be hugely appreciated, thank you. gord.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---