Commit af0a8c3b authored by Deokhyun Lee's avatar Deokhyun Lee

Updating for Assignment is now properly updates in db

parent 45471f2e
...@@ -37,8 +37,15 @@ class AssignmentEditView(UpdateView): ...@@ -37,8 +37,15 @@ class AssignmentEditView(UpdateView):
form_class = AddAssignmentForm form_class = AddAssignmentForm
template_name = 'assignment-edit.html' template_name = 'assignment-edit.html'
# Get the assignment object based on the pk in the URL
def get_object(self, queryset=None):
pk = self.kwargs.get('pk')
return Assignment.objects.get(pk=pk)
def post(self, request, pk): def post(self, request, pk):
form = AddAssignmentForm(request.POST) assignment = self.get_object()
form = AddAssignmentForm(request.POST, instance = assignment)
if form.is_valid(): if form.is_valid():
# onSave is called, the form will have essential data and this includes pk as well. # onSave is called, the form will have essential data and this includes pk as well.
update_assignment = form.save() update_assignment = form.save()
......
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