mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Add debug student account on migrate and added subjects to user serializer
This commit is contained in:
parent
e6c4dd7b9c
commit
db8fd8642f
2 changed files with 5 additions and 2 deletions
|
@ -88,9 +88,9 @@ def create_superuser(sender, **kwargs):
|
||||||
# year_level = '1st Year'
|
# year_level = '1st Year'
|
||||||
# semester = '1st Semester'
|
# 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
|
# 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)
|
username=username, email=email, password=password, first_name=first_name, last_name=last_name)
|
||||||
|
|
||||||
# Activate the superuser
|
# Activate the superuser
|
||||||
|
|
|
@ -11,6 +11,7 @@ from django.contrib.auth.password_validation import validate_password
|
||||||
from courses.models import Course
|
from courses.models import Course
|
||||||
from year_levels.models import Year_Level
|
from year_levels.models import Year_Level
|
||||||
from semesters.models import Semester
|
from semesters.models import Semester
|
||||||
|
from subjects.models import Subject
|
||||||
from django.contrib.gis.geos import Point
|
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)
|
many=False, slug_field='name', queryset=Year_Level.objects.all(), required=False, allow_null=True)
|
||||||
semester = serializers.SlugRelatedField(
|
semester = serializers.SlugRelatedField(
|
||||||
many=False, slug_field='name', queryset=Semester.objects.all(), required=False, allow_null=True)
|
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):
|
class Meta(BaseUserSerializer.Meta):
|
||||||
model = CustomUser
|
model = CustomUser
|
||||||
|
|
Loading…
Reference in a new issue