mirror of
https://github.com/more-tech4-magnum-opus/backend.git
synced 2024-11-25 04:33:44 +03:00
31 lines
792 B
Python
31 lines
792 B
Python
|
from rest_framework import serializers
|
||
|
|
||
|
from marketplace.models import Product
|
||
|
|
||
|
|
||
|
class ProductSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Product
|
||
|
fields = [
|
||
|
"name",
|
||
|
"slug",
|
||
|
"description",
|
||
|
"image",
|
||
|
"image_cropped",
|
||
|
"nft",
|
||
|
"price",
|
||
|
"creator",
|
||
|
]
|
||
|
extra_kwargs = {
|
||
|
"image": {"write_only": True},
|
||
|
"nft": {"read_only": True},
|
||
|
"slug": {"read_only": True},
|
||
|
"image_cropped": {"read_only": True},
|
||
|
"creator": {"read_only": True},
|
||
|
}
|
||
|
|
||
|
def create(self, validated_data):
|
||
|
return Product.objects.create(
|
||
|
**validated_data, creator=self.context["request"].user
|
||
|
)
|