diff --git a/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py b/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py new file mode 100644 index 0000000..0527dd0 --- /dev/null +++ b/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2.2 on 2023-07-04 10:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('semesters', '0001_initial'), + ('courses', '0002_initial'), + ('year_levels', '0001_initial'), + ('accounts', '0003_customuser_subjects'), + ] + + operations = [ + migrations.AlterField( + model_name='customuser', + name='course', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='courses.course'), + ), + migrations.AlterField( + model_name='customuser', + name='semester', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='semesters.semester'), + ), + migrations.AlterField( + model_name='customuser', + name='year_level', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='year_levels.year_level'), + ), + ] diff --git a/stude/accounts/models.py b/stude/accounts/models.py index 24adb8e..80565bf 100644 --- a/stude/accounts/models.py +++ b/stude/accounts/models.py @@ -41,17 +41,17 @@ class CustomUser(AbstractUser): avatar = models.ImageField(upload_to=_get_upload_to, null=True) course = models.ForeignKey( Course, - on_delete=models.CASCADE, + on_delete=models.SET_NULL, null=True ) year_level = models.ForeignKey( Year_Level, - on_delete=models.CASCADE, + on_delete=models.SET_NULL, null=True ) semester = models.ForeignKey( Semester, - on_delete=models.CASCADE, + on_delete=models.SET_NULL, null=True ) subjects = models.ManyToManyField( diff --git a/stude/config/settings.py b/stude/config/settings.py index 8ebcd62..a7ccf2b 100644 --- a/stude/config/settings.py +++ b/stude/config/settings.py @@ -182,3 +182,5 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +DOMAIN = 'stude://' diff --git a/stude/student_status/migrations/0005_alter_studentstatus_subject.py b/stude/student_status/migrations/0005_alter_studentstatus_subject.py new file mode 100644 index 0000000..845a322 --- /dev/null +++ b/stude/student_status/migrations/0005_alter_studentstatus_subject.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.2 on 2023-07-04 10:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('subjects', '0002_subjectstudent_subject_students'), + ('student_status', '0004_alter_studentstatus_study_group'), + ] + + operations = [ + migrations.AlterField( + model_name='studentstatus', + name='subject', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='subjects.subject'), + ), + ] diff --git a/stude/student_status/models.py b/stude/student_status/models.py index b2ca891..2787206 100644 --- a/stude/student_status/models.py +++ b/stude/student_status/models.py @@ -11,7 +11,7 @@ class StudentStatus(models.Model): x = models.FloatField(null=True) y = models.FloatField(null=True) subject = models.ForeignKey( - 'subjects.Subject', on_delete=models.CASCADE, null=True) + 'subjects.Subject', on_delete=models.SET_NULL, null=True) active = models.BooleanField(default=False) timestamp = models.DateField(auto_now_add=True) study_group = models.ManyToManyField(