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.
 
 
 
 
 
 

53 lines
1.4 KiB

from rest_framework.serializers import ModelSerializer
from .models import User
from projects.models import Project
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = (
'avatar',
'financial_info',
'contractor_specializations',
'contractor_status',
'created',
'cro',
'date_of_birth',
'email',
'first_name',
'gender',
'id',
'is_active',
'last_name',
'last_time_visit',
'location',
'username',
'patronym',
'skype',
'website',
)
# read_only_fields = (
# 'is_active',
# 'is_admin',
# )
# def create(self, validated_data):
# return User.objects.create(**validated_data)
# def update(self, inst, validated_data):
# inst.email = validated_data.get('email', inst.email)
# inst.first_name = validated_data.get('first_name', inst.first_name)
# inst.is_active = validated_data.get('is_active', inst.is_active)
# inst.last_name = validated_data.get('last_name', inst.last_name)
# # inst.projects = validated_data.get('projects', inst.projects)
#
# inst.save()
#
# return inst
# import code; code.interact(local=dict(globals(), **locals()))