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.
40 lines
1.1 KiB
40 lines
1.1 KiB
from rest_framework.serializers import ModelSerializer
|
|
|
|
from .models import User
|
|
from projects.models import Project
|
|
|
|
|
|
class UserSerializer(ModelSerializer):
|
|
class Meta:
|
|
model = User
|
|
|
|
fields = (
|
|
'id',
|
|
'email',
|
|
'first_name',
|
|
'is_active',
|
|
'is_admin',
|
|
'last_name',
|
|
'projects',
|
|
)
|
|
|
|
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()))
|
|
|