Add slug to carousel serializer

This commit is contained in:
Kuroshini 2019-09-30 14:05:38 +03:00
parent b1e09d806a
commit beb031d0b6
2 changed files with 6 additions and 0 deletions

View File

@ -337,6 +337,11 @@ class Carousel(models.Model):
if hasattr(self.content_object, 'image_url'):
return self.content_object.image_url
@property
def slug(self):
if hasattr(self.content_object, 'slug'):
return self.content_object.slug
@property
def model_name(self):
return self.content_object.__class__.__name__

View File

@ -157,6 +157,7 @@ class CarouselListSerializer(serializers.ModelSerializer):
'image',
'vintage_year',
'last_award',
'slug',
]
def get_last_award(self, obj):