diff --git a/stude/accounts/models.py b/stude/accounts/models.py index 0ce2968..191ea70 100644 --- a/stude/accounts/models.py +++ b/stude/accounts/models.py @@ -88,9 +88,9 @@ def create_superuser(sender, **kwargs): # year_level = '1st Year' # semester = '1st Semester' - if not CustomUser.objects.filter(username=username).exists(): + if not User.objects.filter(username=username).exists(): # Create the superuser with is_active set to False - user = CustomUser.objects.create( + user = User.objects.create_user( username=username, email=email, password=password, first_name=first_name, last_name=last_name) # Activate the superuser diff --git a/stude/accounts/serializers.py b/stude/accounts/serializers.py index 4036c84..7f70f5f 100644 --- a/stude/accounts/serializers.py +++ b/stude/accounts/serializers.py @@ -11,6 +11,7 @@ from django.contrib.auth.password_validation import validate_password from courses.models import Course from year_levels.models import Year_Level from semesters.models import Semester +from subjects.models import Subject from django.contrib.gis.geos import Point @@ -26,6 +27,8 @@ class CustomUserSerializer(BaseUserSerializer): many=False, slug_field='name', queryset=Year_Level.objects.all(), required=False, allow_null=True) semester = serializers.SlugRelatedField( many=False, slug_field='name', queryset=Semester.objects.all(), required=False, allow_null=True) + subjects = serializers.SlugRelatedField( + many=True, slug_field='name', queryset=Subject.objects.all(), required=False, allow_null=True) class Meta(BaseUserSerializer.Meta): model = CustomUser