feat: update view of Assignments app

Create and use HTML template to output content from models in desired format.
parent ec3d09ba
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1> ASSIGNMENTS: </h1>
{% for assignment in assignment_entries %}
<p>
Assignment Name: {{assignment.name}}<br>
Description: {{assignment.description}}<br>
Perfect Score: {{assignment.max_points}}<br>
Passing Score: {{assignment.passing_score}}<br>
Course/Section: {{assignment.course.course_code}} {{assignment.course.course_title}} | {{assignment.course.section}}
</p>
{% endfor %}
</body>
</html>
from django.http import HttpResponse from django.http import HttpResponse
from django.template import loader
from .models import Course, Assignment
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse("This is the Assignments page!") assignments = Assignment.objects.all()
\ No newline at end of file template = loader.get_template('assignments/index.html')
context = {
'assignment_entries': assignments
}
return HttpResponse(template.render(context, request))
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