Fixed model relations in views

parent 6765bbad
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
import os
def index(request):
output = f"Widget's Assignments Page\n"
output = f"Widget's Assignments Page<br><br>"
count = Assignment.objects.all().count()
for i in range(1, count + 1):
assignments = Assignment.objects.get(id=i)
courses = Course.objects.get(id=i)
output += (f"Assignment Name: {assignments.name}\n"
f"Description: {assignments.description}\n"
f"Perfect Score: {assignments.perfect_score}\n"
f"Passing Score: {assignments.passing_score}\n"
f"Course/Section: {courses.code} {courses.title}-{courses.section}\n\n")
output += f"""Assignment Name: {assignments.name}<br>
Description: {assignments.description}<br>
Perfect Score: {assignments.perfect_score}<br>
Passing Score: {assignments.passing_score}<br>
Course/Section: {assignments.course.code} {assignments.course.title}-{cassignments.course.section}<br>
<br>"""
return HttpResponse(output)
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