I am trying to switch form a functional view that edits and submits a form to class based view, UpdateView. I need to access the form. Until now I use this view: @login_required def...


I am trying to switch form a functional view that edits and submits a form to class based view, UpdateView. I need to access the form.


Until now I use this view:



@login_required def edit_sale_view(request, id): instance = get_object_or_404(Sale, id=id) form = EditSaleForm(instance=instance) if request.method == "POST": form = EditSaleForm(request.POST, instance=instance) if form.is_valid(): obj = form.save(commit=False) obj.user = request.user obj.save() return JsonResponse({'msg': 'Data saved'}) else: return JsonResponse({'msg': 'Data not saved'}) return HttpResponse(form.as_p())

Theform.as_p()is important because it is used in the form that is displayed in a modal window.

Nov 15, 2019
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here