added two functions to render ListView and DetailView pages

parent 1331f6ec
from django.shortcuts import render from django.shortcuts import render
from .models import Assignment from .models import Assignment, Course
def assignments_view(request): def ListView_view(request, *args, **kwargs):
objects_set = { list_context = {
"all_assignments": [obj for obj in Assignment.objects.all()] "all_courses": [obj for obj in Course.objects.all()]
} }
return render(request, "assignments_template.html", objects_set) return render(request, "assignments/ListView.html", list_context)
def DetailView_view(request, pk):
detailed_context = {
"assignment": Assignment.objects.get(id=pk)
}
return render(request, "assignments/DetailView.html", detailed_context)
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