Edited views.py to display Assignment entries with corresponding Course

parent c948f654
from django.shortcuts import HttpResponse
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
# Create your views here.
def index(request):
return HttpResponse("This is the Assignments page!")
heading = 'ASSIGNMENTS:<br><br>'
assignments = Assignment.objects.all()
body = ''
for assignment in assignments:
courses = Course.objects.filter(course_code__exact=assignment.course_code)
body += 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>'.format(
assignment.name, assignment.description, assignment.max_points, assignment.passing_score
)
for course in courses:
body += 'Course/Section: {} {} {}<br><br>'.format(
course.course_code, course.course_title, course.section
)
return HttpResponse(heading + body)
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