from rest_framework import serializers
from .models import User

class UserSerializer(serializers.ModelSerializer):
    url         = serializers.SerializerMethodField(read_only = True)
    class Meta:
        model = User
        fields = [
        'url',
        'user_id',
        'is_guide'
        ]

    def get_url(self,obj):
        request = self.context.get("request")
        return obj.get_api_url(request=request)

    def validate_name(self,value):
        qs = User.objects.filter(user_id__iexact=value)
        if qs.exists():
            raise serializers.ValidationError("This user already exists")

540965fc7a875fc676fe5d99828821f5cce95c44
<mask token>


class UserSerializer(serializers.ModelSerializer):
    <mask token>


    class Meta:
        model = User
        fields = ['url', 'user_id', 'is_guide']

    def get_url(self, obj):
        request = self.context.get('request')
        return obj.get_api_url(request=request)
    <mask token>

<mask token>


class UserSerializer(serializers.ModelSerializer):
    <mask token>


    class Meta:
        model = User
        fields = ['url', 'user_id', 'is_guide']

    def get_url(self, obj):
        request = self.context.get('request')
        return obj.get_api_url(request=request)

    def validate_name(self, value):
        qs = User.objects.filter(user_id__iexact=value)
        if qs.exists():
            raise serializers.ValidationError('This user already exists')

<mask token>


class UserSerializer(serializers.ModelSerializer):
    url = serializers.SerializerMethodField(read_only=True)


    class Meta:
        model = User
        fields = ['url', 'user_id', 'is_guide']

    def get_url(self, obj):
        request = self.context.get('request')
        return obj.get_api_url(request=request)

    def validate_name(self, value):
        qs = User.objects.filter(user_id__iexact=value)
        if qs.exists():
            raise serializers.ValidationError('This user already exists')

from rest_framework import serializers
from .models import User


class UserSerializer(serializers.ModelSerializer):
    url = serializers.SerializerMethodField(read_only=True)


    class Meta:
        model = User
        fields = ['url', 'user_id', 'is_guide']

    def get_url(self, obj):
        request = self.context.get('request')
        return obj.get_api_url(request=request)

    def validate_name(self, value):
        qs = User.objects.filter(user_id__iexact=value)
        if qs.exists():
            raise serializers.ValidationError('This user already exists')

from rest_framework import serializers
from .models import User

class UserSerializer(serializers.ModelSerializer):
    url         = serializers.SerializerMethodField(read_only = True)
    class Meta:
        model = User
        fields = [
        'url',
        'user_id',
        'is_guide'
        ]

    def get_url(self,obj):
        request = self.context.get("request")
        return obj.get_api_url(request=request)

    def validate_name(self,value):
        qs = User.objects.filter(user_id__iexact=value)
        if qs.exists():
            raise serializers.ValidationError("This user already exists")
