[Answered ]-I am creating Django web application for additional payments like Shift allowance on call etc, I am getting HttpResponse error

1👍

There is no else if form is not valid. If form is not valid it should render the template with form errors like (and check if ar_status object exists) :

def update_status(request, id):
    try:
         ar_status = Shift.objects.get(pk=id)
    except ObjectDoesNotExist:
         print('There is no shift object with this id')
         return redirect('/')
    if request.method == 'POST':
       
        fm = shiftforms(request.POST, instance=ar_status)
        if fm.is_valid():
            fm.save()
            return redirect('/')
        else:
            print(fm.errors)
    else:
        ar_status=Shift.objects.get(id=id)
        fm = shiftforms(instance=ar_status)
    return render(request, "update.html", {"Shift":ar_status, "form": fm})

notice that the retun with render is no longer part of else statment.

Leave a comment