I'm having a simple Gallery
model, that is related to an Image
model via a many-to-many relationship through a table that has an ordering
-attribute:
# models.py
class Image(models.Model):
....
class Gallery(models.Model):
images = models.ManyToManyField(Image, through='ImageGallery')
....
class ImageGallery(models.Model)
image = models.ForeignKey(Image)
gallery = models.ForeignKey(Gallery)
ordering = models.PositiveIntegerField(_('ordering'), default=0)
# admin.py
class ImageGalleryAdmin(admin.ModelAdmin):
model = ImageGallery
class GalleryAdmin(admin.ModelAdmin):
inlines = (ImageGalleryAdmin,)
I'm editing the 'through' table via an inline admin.
What I'd like to do is to be able to upload/edit the images directly in the inline admin, so I'd like to know if anybody knows an exisiting snippet, that allows me to edit the field of the 'through'-table together with the fields of the referenced model (the image), not needing to edit the foreign key select....