Value does not change in admin dahboard and html template that has a tag of the value, inrthe view function where the change happens,it print the correct value that was changed (order.status)
def chef_order(request):
chef = request.user.vendor
orders = chef.orders.all()
if 'btnform1' in request.POST:
orderid = request.POST.get("orderid")
order = Order.objects.get(pk=int(orderid))
sts = 'confirmed'
order.status = "confirmed"
print(order.get_status_display())
CodePudding user response:
order = Order.objects.get(pk=int(orderid))
This returns an instance object of the database record. However, it's not the record itself. When you update the field on the instance, you need to save it back to the database.
order.status = "confirmed"
order.save()