Commit f0a4818f authored by Joerell Frank Yee Lao's avatar Joerell Frank Yee Lao

Added a model nameed Course, it contains course code, course title, and...

Added a model nameed Course, it contains course code, course title, and section. Added a relationship to assignment and course
parent 01034b9f
...@@ -2,5 +2,7 @@ from django.contrib import admin ...@@ -2,5 +2,7 @@ from django.contrib import admin
# Register your models here. # Register your models here.
from .models import Assignment from .models import Assignment
from .models import Course
admin.site.register(Course)
admin.site.register(Assignment) admin.site.register(Assignment)
# Generated by Django 3.2.12 on 2022-04-04 03:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_rename_assignments_assignment'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('course_code', models.CharField(max_length=10)),
('course_title', models.CharField(max_length=500)),
('section', models.CharField(max_length=3)),
],
),
]
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=500)
section = models.CharField(max_length=3)
class Assignment(models.Model): class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE)
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)
def __str__(self): def __str__(self):
return self.name return self.name
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