Removed unnecessary imports and updated the FBV implementation for /assignments/

parent d3fcdca9
from django.http import HttpResponse
from django.shortcuts import render
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment, Course
from .forms import AssignmentForm, CourseForm
from .models import Assignment
from .forms import AssignmentForm
class AssignmentDetailsView(DetailView):
......@@ -27,16 +24,8 @@ class EditAssignmentView(UpdateView):
def index(request):
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)
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}-{assignments.course.section}<br>
<br>"""
return HttpResponse(output)
assignments = Assignment.objects.all()
context = {
'assignments': assignments
}
return render(request, 'assignments/assignments.html', 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