Ошибка валидности формы - пишет ошибку форма не валидная
@login_required
def order_create(request):
if request.method == 'POST':
form = OrderCreateForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
print(form)
if cd['id_checked'] == 1:
order = form.save()
user = request.user.usrid.listusers_id
baskets = Basket.objects.filter(user=user).select_related('user', 'product',
'basket_sklad', 'quantity').prefetch_related(
'product__category__parent', 'product__brand__clt1__client_id', 'product__product_sklad')
for item in baskets:
OrderItem.objects.create(nomer_order=order,
product=item['product'],
price=item['price'],
quantity=item['quantity'])
baskets.clear()
return render(request,
'created.html',
{'baskets': baskets,
'total_quantity': total_quantity,
'total_sum': total_sum,
'category_count': category_count,
'results': baskets})
` <div class="col-xl-4 col-lg-5 col-12 text-right addcartpost2">
<div class="row order_tab pr-2">
<div class="col-lg-5 col-md-5 col-5 text-right">
<form class="addcartpost" action="." method="POST">
{% if request.user.usrid.riteil == True %}
{% comment %} Если включена цена ритейл {% endcomment %}
<div class="col-lg-3 col-md-2 col-2 text-right amount retail">
</div>
{% else %}
{% comment %} Если отключена цена ритейл {% endcomment %}
<div class=" col-lg-3 col-md-2 col-2 text-right amount">
{{basket.product.user_max2|floatformat:"2g"}}
</div>/{{ basket.product.shtuk_e}}
</div>
<div class="col-lg-2 col-md-1 col-1 text-right">{{basket.quantity}} {{ basket.product.shtuk_e}}</div>
<div class="col-lg-3 col-md-2 col-2 text-right amount"><x class="sum">{{basket.summa|floatformat:"2g"}}</x></div>
<div class="col-auto" id="id_checked"><input class="checkbox" id="id_checked" type="checkbox" checked name="g1" value="1"></div>
</div>
{% endif %}
</form>
<div class="row mx-0">
<div class="col-md-6 col-12 mt-4 px-0">
<form class="addcartpost" action="." method="POST">
<div class="form-group">
Комментарий к заявке:
<textarea id="comment" name="title" rows="3" class="col-12" value="" placeholder="">
</textarea>
</div>
{% csrf_token %}
<p><input type="submit" value="Place order"></p>
</form>
</div>
`
Вернуться на верх