Taming the email jungle at example.com

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
How would you create a custom email validation for a User serializer in Django Rest Framework that only allows emails from the example.com domain?
Reorder lines using drag or arrows. Adjust indentation with left buttons
                fields = ['id', 'username', 'email']
              
                from rest_framework import serializers
              
                model = User
              
                class Meta:
              
                class UserSerializer(serializers.ModelSerializer):
              
                return value
              
                if not value.endswith('@example.com'):
              
                raise serializers.ValidationError("Email must be from example.com domain")
              
                def validate_email(self, value):
              

Create a free account to access the full topic