When working with Django and in addition studying it, I’ve used to learn but additionally write related code. class UserSerializer(serializers.ModelSerializer): class Meta: mannequin = Consumer fields = [“username”, “password”, “email”] def create(self, validated_data): username = validated_data.get(“username”) if username: strive: Consumer.objects.get(username=username) increase ValidationError({“consumer”: “This consumer already exists.”}) besides ObjectDoesNotExist: cross return Consumer.objects.create(**validated_data) Enter fullscreen modeExit fullscreen…

Read More