Imported the new ModelForms and created class-based views to create or update data

parent 3ec06828
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment 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
class AssignmentDetailsView(DetailView):
model = Assignment
template_name = 'assignments/assignment-details.html'
class AddAssignmentView(CreateView):
model = Assignment
form_class = AssignmentForm
template_name = 'assignments/assignment-add.html'
class EditAssignmentView(UpdateView):
model = Assignment
form_class = AssignmentForm
template_name = 'assignments/assignment-edit.html'
def index(request): def index(request):
output = f"Widget's Assignments Page<br><br>" output = f"Widget's assignments Page<br><br>"
count = Assignment.objects.all().count() count = Assignment.objects.all().count()
for i in range(1, count + 1): for i in range(1, count + 1):
......
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