我有这个视图来显示以前填充的数据,这些数据只填充在管理面板中:from .models import (Token, Sell, LogisticCost, IncomeCost, FinalPayment, CustomerServiceCost, Fatura)def product_list(request): context = {'product_list': ProductList.objects.filter(client=request.user.id).all(), 'data_payment': Fatura.objects.all()} return render(request, 'Clientes/list_products.html', context)这是更新这些值的视图:class UpdateProduct(UpdateView): model = ProductList context_object_name = 'product_list' template_name = 'Clientes/update_product.html' fields = ['name', 'description', 'cost_price', 'sell_price', 'ncm']我在更新页面中的表单是:<form method="post" action="{% url 'client:product_list' %}"> {% csrf_token %} {{ form }} <button class="btn btn-inverse" type="submit">Atualizar</button></form>我的更新页面按预期工作,显示与所选对象相关的每个值,但是当我提交表单时,模型没有改变。不更新值会发生什么?
2 回答

神不在的星期二
TA贡献1963条经验 获得超6个赞
毕竟,我从表单中删除了操作并将变量添加success_url = reverse_lazy('client:product_list')
到我的 UpdateView。那解决了问题。
添加回答
举报
0/150
提交
取消