JourneyJoker/gallery/mixins.py

13 lines
376 B
Python
Raw Normal View History

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