i hope database wont get fcked
dynamic fields for product
This commit is contained in:
@@ -4,10 +4,7 @@ from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
class InStuckColorsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = InStuckColors
|
||||
fields = ['color', 'in_stuck']
|
||||
|
||||
|
||||
|
||||
class DetailSerializer(serializers.ModelSerializer):
|
||||
@@ -24,7 +21,7 @@ class ProductDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
class DynamicProductSerializer(serializers.ModelSerializer):
|
||||
colors = InStuckColorsSerializer(many=True, read_only=True)
|
||||
|
||||
price = serializers.SerializerMethodField()
|
||||
is_new = serializers.SerializerMethodField()
|
||||
related_products = serializers.SerializerMethodField()
|
||||
@@ -45,9 +42,9 @@ class DynamicProductSerializer(serializers.ModelSerializer):
|
||||
model = ProductModel
|
||||
fields = "__all__"
|
||||
view_type = {
|
||||
'list': ['name', 'price', 'image1', 'video', 'rating', 'discount', 'slug', 'category', 'colors'],
|
||||
'instance': ['name', 'description', 'price', 'image1', 'image2', 'image3', 'video', 'rating', 'discount', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'colors', 'related_products', 'details', 'in_pack_items'],
|
||||
'chat': ['name', 'description', 'price', 'in_stock', 'discount', 'colors']
|
||||
'list': ['name', 'price', 'image1', 'video', 'rating', 'discount', 'slug', 'category', ],
|
||||
'instance': ['name', 'description', 'price', 'image1', 'image2', 'image3', 'video', 'rating', 'discount', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'related_products', 'details', 'in_pack_items'],
|
||||
'chat': ['name', 'description', 'price', 'in_stock', 'discount', ]
|
||||
}
|
||||
|
||||
def get_price(self, obj):
|
||||
|
||||
Reference in New Issue
Block a user