Use simpler method for HttpResponse to display data from Assignments app

parent 6d8d23a3
......@@ -10,6 +10,24 @@ def index(request):
def assignments(request):
all_assignments = models.Assignment.objects.all()
template = get_template('assignments.html')
output = template.render({'assignments': all_assignments})
return HttpResponse(output)
# template = get_template('assignments.html')
# output = template.render({'assignments': all_assignments})
# return HttpResponse(output)
output = ""
for a in all_assignments:
name = a.name
desc = a.description
pfscore = str(a.max_points)
psscore = str(a.passing_score)
ccode = a.course.course_code
ctitle = a.course.course_title
csection = a.course.section
record = ("Assignment Name: " + name + "<br>Description: " + desc +
"<br>Perfect Score: " + pfscore + "<br>Passing Score: " + psscore +
"<br>Course/Section: " + ccode + " " + ctitle + " " + csection)
output += record + "<br><br>"
return HttpResponse('<h1>ASSIGNMENTS: </h1>' + 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