Exemplo n.º 1
0
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")
Exemplo n.º 2
0
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")
Exemplo n.º 3
0
class AdvertDetailSer(serializers.ModelSerializer):
    """Для вывода полного объявления"""
    category = CategorySer()
    filters = FilterAdvertSer()
    images = GallerySer()

    class Meta:
        model = Advert
        fields = ('category', 'filters', 'subject', 'description', 'images',
                  'file', 'price', 'created', 'user')
Exemplo n.º 4
0
class AdvertListSer(serializers.ModelSerializer):
    """Для вывода списка объявлений"""
    category = CategorySer()
    filters = FilterAdvertSer()
    images = GallerySer()

    class Meta:
        model = Advert
        fields = ('category', 'filters', 'subject', 'images', 'price',
                  'created', 'slug')
Exemplo n.º 5
0
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")
Exemplo n.º 6
0
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")
Exemplo n.º 7
0
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