Fixed integrity issues with on_delete for customuser

This commit is contained in:
Keannu Bernasol 2023-07-04 18:06:47 +08:00
parent 9196bfa602
commit f6cbe1941e
5 changed files with 58 additions and 4 deletions

View file

@ -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'),
),
]

View file

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

View file

@ -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://'

View file

@ -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'),
),
]

View file

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