Commit 2adda0d0 authored by Chester Tan's avatar Chester Tan

added fields to Assignment model

added template directory in settings.py
created views template for assignments
added context to the assignments view
parent e7d7c85e
......@@ -7,3 +7,12 @@ class Assignment(models.Model):
def __str__(self):
return self.name
@property
def passing_score(self):
return int(self.max_points*.6)
class Course(models.Model):
course_code = models.SlugField(max_length=10)
course_title = models.SlugField(max_length=100)
section = models.CharField(max_length=3)
\ No newline at end of file
<h1>ASSIGNMENTS: </h1>
{% for assignment in assignments %}
<p>Assignment Name: {{assignment.name}}</p>
<p>Description: {{assignment.description}}</p>
<p>Perfect Score: {{assignment.max_points}}</p>
<p>Passing Score: {{assignment.passing_score}}</p><br>
{% endfor %}
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment
def assignments(request):
return HttpResponse("This is the Assignments Page!")
assignments_context = Assignment.objects.all()
context = {'assignments':assignments_context
}
return render(request, 'assignments/assignments.html', context)
# Generated by Django 4.0.3 on 2022-03-28 12:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateField(auto_now_add=True),
),
]
......@@ -62,7 +62,9 @@ ROOT_URLCONF = 'widget_Francoconuts.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [
BASE_DIR / 'templates'
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
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