Given the following, where a Product can be associated with multiple Images via 
a GFK:


# models:

class Image(models.Model):
    image = ImageField(...)

class ImageAssociation(models.Model):
    image = models.ForeignKey(Image, related_name='associations')
    content_object = GenericForeignKey()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField(db_index=True)

class Product(models.Model):
    title = models.CharField(max_length=255)
    images = GenericRelation('images.ImageAssociation', 
related_query_name='products')


How would I go about adding/changing/deleting Products when editing an Image in 
the admin? I can easily add/change/delete `ImageAssociation` via admin inlines, 
but I am looking to take it another level: add/change/delete related `Product` 
instances.


I've looked at nesting inlines via 
https://github.com/theatlantic/django-nested-admin, but it looks like the 
relations are not set up in a way that works - or at least I cannot figure out 
how to arrange things.


Is it possible to set up a custom inline with a `Product` modelform that 
automatically creates/removes/updates `ImageAssociation` relational instances 
as well?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7f9b91c-10c5-4c6f-b15f-c2e3cf3ce5ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to