Commit 6b1f7ad6 authored by Deokhyun Lee's avatar Deokhyun Lee

now, edit view properly gets existing data and properly updates accordingly

parent 9dc25d9d
...@@ -4,6 +4,7 @@ from . import views ...@@ -4,6 +4,7 @@ from . import views
# url for assignments # url for assignments
urlpatterns = [ urlpatterns = [
path('', views.assignments_view, name='assignment'), path('', views.assignments_view, name='assignment'),
path('<int:pk>/details', views.AssignmentDetailView.as_view(), name='assignment_details'),
path('add', views.AssignmentAddListView.as_view(), name="assignment_add" ), path('add', views.AssignmentAddListView.as_view(), name="assignment_add" ),
path('<int:pk>/details', views.AssignmentDetailView.as_view(), name='assignment_details'),
path('<int:pk>/edit', views.AssignmentEditView.as_view(), name='assignment_edit'),
] ]
\ No newline at end of file
...@@ -29,11 +29,11 @@ class AssignmentAddListView(CreateView): ...@@ -29,11 +29,11 @@ class AssignmentAddListView(CreateView):
# pass the pk and redirect. # pass the pk and redirect.
return redirect('assignment_details', pk = new_assignment.pk) return redirect('assignment_details', pk = new_assignment.pk)
else: else:
return render(request, 'book_details.html', {'form': form}) return render(request, 'assignment_details.html', {'form': form})
# assignment for edditing CBV implementation. # assignment for edditing CBV implementation.
class BookEditView(UpdateView): class AssignmentEditView(UpdateView):
model = Assignment() model = Assignment
form_class = AddAssignmentForm form_class = AddAssignmentForm
template_name = 'assignment-edit.html' template_name = 'assignment-edit.html'
...@@ -45,4 +45,4 @@ class BookEditView(UpdateView): ...@@ -45,4 +45,4 @@ class BookEditView(UpdateView):
# pass the pk and redirect. # pass the pk and redirect.
return redirect('assignment_details', pk = update_assignment.pk) return redirect('assignment_details', pk = update_assignment.pk)
else: else:
return render(request, 'book_details.html', {'form': form}) return render(request, 'assignment_details.html', {'form': form})
\ No newline at end of file \ 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