From 83580f9aa506c78e187304f922e6915a13dd4f11 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Thu, 18 Jan 2024 13:38:12 +0800 Subject: [PATCH] Fix username in registration --- equipment_tracker/accounts/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/equipment_tracker/accounts/serializers.py b/equipment_tracker/accounts/serializers.py index 9130474..c8787e4 100644 --- a/equipment_tracker/accounts/serializers.py +++ b/equipment_tracker/accounts/serializers.py @@ -21,6 +21,7 @@ class CustomUserSerializer(BaseUserSerializer): class UserRegistrationSerializer(serializers.ModelSerializer): + username = serializers.CharField(required=True) email = serializers.EmailField(required=True) course = serializers.ChoiceField( choices=CustomUser.COURSE_CHOICES, allow_blank=True, allow_null=True) @@ -32,7 +33,7 @@ class UserRegistrationSerializer(serializers.ModelSerializer): model = CustomUser # Use your custom user model here fields = ('username', 'email', 'password', 'course', 'section', 'first_name', 'last_name') - read_only_fields = ('username', 'email', 'is_teacher', 'is_technician') + read_only_fields = ('email', 'is_teacher', 'is_technician') def validate(self, attrs): user = self.Meta.model(**attrs)