如何在Django的框中显示烤面包机通知?

时间:2018-05-11 11:19:39

标签: django django-forms django-templates django-views

预期输出就像

Expected output image

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 %}

请告诉我该怎么做?

0 个答案:

没有答案