from django.contrib.contenttypes.fields import GenericRelation from django.db import models from .models import Image class GalleryMixin(models.Model): image_set = GenericRelation(Image) def add_image(self, image, upload_path=None): Image.objects.create(image=image, content_object=self, upload_path=upload_path) class Meta: abstract = True