Commit 211b1649 authored by Chester Tan's avatar Chester Tan

removed leftover function based view

added alphabetical order to AssignmentListView
parent f6fd0c33
from django.urls import path
from .views import assignments, AssignmentDetailView, AssignmentListView
from .views import AssignmentDetailView, AssignmentListView
urlpatterns = [
path('', AssignmentListView.as_view(), name='assignments'),
......
......@@ -3,17 +3,13 @@ from .models import Assignment, Course
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
def assignments(request):
assignments_context = Assignment.objects.all()
courses = Course.objects.order_by('course_code')
context = {
'assignments':assignments_context,
'courses':courses,
}
return render(request, 'assignments/assignments.html', context)
class AssignmentListView(ListView):
model = Course
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context["object_list"] = Course.objects.order_by("course_code")
return context
class AssignmentDetailView(DetailView):
model = Assignment
\ No newline at end of file
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