Commit 7a35f9eb authored by Joan Denise Nocos's avatar Joan Denise Nocos

feat: added foreign key to Assignment model that associates an assignment with a course

parent 51253f93
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import Assignment from .models import Assignment, Course
admin.site.register(Assignment) admin.site.register(Assignment)
admin.site.register(Course)
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-04-05 10:23
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_course'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='course',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
migrations.AlterField(
model_name='course',
name='course_title',
field=models.CharField(max_length=255),
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=255)
section = models.CharField(max_length=3)
class Assignment(models.Model): class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE)
course.null = True
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
description = models.CharField(max_length=500) description = models.CharField(max_length=500)
max_points = models.IntegerField(default=0) max_points = models.IntegerField(default=0)
...@@ -9,8 +16,3 @@ class Assignment(models.Model): ...@@ -9,8 +16,3 @@ class Assignment(models.Model):
def _str_(self): def _str_(self):
return self.name return self.name
\ No newline at end of file
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=256)
section = models.CharField(max_length=3)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment