class AdvertDetailSer(serializers.ModelSerializer): category = CategorySer() filters = FilterAdvertSer() images = GallerySer(read_only=True) class Meta: model = Advert fields = ("category", "filters", "subject", "description", "images", "file", "price", "created", "user")
class AdvertListSer(serializers.ModelSerializer): category = CategorySer() filters = FilterAdvertSer() images = GallerySer(read_only=True) class Meta: model = Advert fields = ("id", "category", "filters", "subject", "images", "price", "created", "slug")
class AdvertDetailSer(serializers.ModelSerializer): """Для вывода полного объявления""" category = CategorySer() filters = FilterAdvertSer() images = GallerySer() class Meta: model = Advert fields = ('category', 'filters', 'subject', 'description', 'images', 'file', 'price', 'created', 'user')
class AdvertListSer(serializers.ModelSerializer): """Для вывода списка объявлений""" category = CategorySer() filters = FilterAdvertSer() images = GallerySer() class Meta: model = Advert fields = ('category', 'filters', 'subject', 'images', 'price', 'created', 'slug')
class AdvertListSer(serializers.ModelSerializer): """Для виводу списку оголошень""" category = CategorySer() filters = FilterAdvertSer() images = GallerySer(read_only=True) user = UserSerialiser() class Meta: model = Advert fields = ("id", "user", "category", "filters", "subject", "images", "price", "created", "slug", "moderation")
class AdvertDetailSer(serializers.ModelSerializer): """Для виводу повного оголошення""" category = CategorySer() filters = FilterAdvertSer() # date = DateAdvertSer() images = GallerySer(read_only=True) user = UserSerialiser() profile = ProfileSer(read_only=True, many=True) class Meta: model = Advert fields = ("user", "profile", "category", "filters", "subject", "description", "images", "price", "created", "user", "moderation")
class AdvertCreateSer(serializers.ModelSerializer): """Добавление объявления""" images = GallerySer() class Meta: model = Advert fields = ( "category", "filters", "date", "subject", "description", "price", # "user" "images") def create(self, request): request["user"] = self.context['request'].user advert = Advert.objects.create(**request) return advert