コード例 #1
0
class ProductCartSerializer(serializers.ModelSerializer):
    brand = DallizBrandField()
    osm_url = serializers.URLField(source='url')
    price = PriceField(source='history_set')

    class Meta:
        model = Product
        fields = ('reference', 'name', 'brand', 'osm_url', 'price',
                  'image_url')
コード例 #2
0
class HistorySerializer(serializers.ModelSerializer):
    # description = DescriptionSerializer(source = 'product')
    package = PackageSerializer(source='product')
    brand = DallizBrandField(source='product.brand')
    reference = serializers.CharField(source='product.reference')
    unit = serializers.RelatedField(source='product.unit')
    osm_url = serializers.URLField(source='product.url')
    image_url = serializers.URLField(source='product.image_url')
    name = serializers.CharField(source='product.name')

    class Meta:
        model = History
        exclude = ('html', 'id', 'product')
コード例 #3
0
class ProductSerializer(serializers.ModelSerializer):
    brand = DallizBrandField()
    history = HistoryField(source='*')
    package = PackageSerializer(source='*')
    promotions = serializers.PrimaryKeyRelatedField(many=True,
                                                    source='promotion_set')
    description = DescriptionSerializer(source='*')
    osm_url = serializers.URLField(source='url')
    quantity_in_cart = QuantityInCart(source='*')

    class Meta:
        model = Product
        exclude = ('url', 'package_quantity', 'package_measure',
                   'package_unit', 'ingredients', 'valeur_nutritionnelle',
                   'conservation', 'conseil', 'composition', 'stemmed_text',
                   'html', 'exists', 'id', 'comment', 'categories',
                   'dalliz_category', 'tag', 'created', 'updated')
        depth = 1