预期输出就像
Views.py
def UpdateProducts(request,id):
if request.method == 'POST':
form = ProductsForm(request.POST, request.FILES)
if form.is_valid():
data = Product.objects.get(pk=id)
form = ProductsForm(request.POST,request.FILES, instance=data)
form.save()
messages.success(request, "The Subscriber has been successfully added")
return redirect('/')
else:
messages.error(request, "Sorry the data has not been entered to the database")
HTML
{% for message in messages %}
toastr.{{ message.tags }}({{ message }});
{% endfor %}
请告诉我该怎么做?