You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.6 KiB

from generic_relations.relations import GenericRelatedField
from rest_framework.serializers import ModelSerializer, ImageField, FileField, SerializerMethodField, PrimaryKeyRelatedField, ReadOnlyField
from .models import WorkSell, WorkSellPhoto
from common.serializers import LocationSerializer
from projects.serializers import BuildingClassficationSerializer, ConstructionTypeSerializer
from specializations.serializers import SpecializationSerializer
from users.serializers import UserSerializer
class WorkSellPhotoSerializer(ModelSerializer):
img = ImageField()
worksell_id = PrimaryKeyRelatedField(read_only=True, source='worksell')
class Meta:
model = WorkSellPhoto
fields = (
'id',
'img',
'worksell_id',
)
class WorkSellSerializer(ModelSerializer):
building_classification = BuildingClassficationSerializer()
construction_type = ConstructionTypeSerializer()
contractor = UserSerializer()
id = ReadOnlyField()
location = LocationSerializer()
photos = WorkSellPhotoSerializer(many=True)
specialization = SpecializationSerializer()
class Meta:
model = WorkSell
fields = (
'budget',
'building_classification',
'construction_type',
'contractor',
'created',
'currency',
'description',
'id',
'location',
'name',
'photos',
'specialization',
'term',
'term_type',
)