diff --git a/studyguides/apps/courses/models.py b/studyguides/apps/courses/models.py index 135baa8..fef3f98 100644 --- a/studyguides/apps/courses/models.py +++ b/studyguides/apps/courses/models.py @@ -16,8 +16,6 @@ class Course(models.Model): id = models.AutoField(primary_key = True) name = models.CharField(max_length=100, unique = True) - units = models.ManyToManyField("Guide", related_name="course") - def __str__(self): return self.name @@ -25,6 +23,7 @@ class Guide(models.Model): id = models.AutoField(primary_key = True) name = models.CharField(max_length=100) + course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True) url = models.URLField(max_length=300) def __str__(self): diff --git a/studyguides/studyguides/apps/courses/migrations/0002_auto_20201015_0934.py b/studyguides/studyguides/apps/courses/migrations/0002_auto_20201015_0934.py new file mode 100644 index 0000000..d55fed6 --- /dev/null +++ b/studyguides/studyguides/apps/courses/migrations/0002_auto_20201015_0934.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.2 on 2020-10-15 13:34 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('courses', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='course', + name='units', + ), + migrations.AddField( + model_name='guide', + name='course', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='courses.course'), + ), + ]