Add debug student account on migrate and added subjects to user serializer

This commit is contained in:
Keannu Bernasol 2023-07-18 16:01:19 +08:00
parent e6c4dd7b9c
commit db8fd8642f
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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