<form action="{% url 'cart:cart_modificate' product.id %}" method="post">
{% csrf_token %}
<input type="submit" value="increment" />
<input type="submit" value="decrement" />
</form>
<form action="{% url 'cart:cart_modificate' %}" method="post">
{% csrf_token %}
<input type="hidden" name="id" value="{{product.id}}" />
<input type="hidden" name="increment" value="increment" />
<input type="hidden" name="decrement" value='None' />
<input type="submit" value="+" />
</form>
<form action="{% url 'cart:cart_modificate' %}" method="post">
{% csrf_token %}
<input type="hidden" name="id" value="{{product.id}}" />
<input type="hidden" name="decrement" value="decrement" />
<input type="hidden" name="increment" value='None' />
<input type="submit" value="-" />
</form>
def cart_modificate(request):
cart = Cart(request)
if request.method == 'POST':
product_id = request.POST['id']
product = get_object_or_404(Product, id=product_id)
if request.POST['increment'] != 'None':
increment = request.POST['increment']
decrement = None
else:
decrement = request.POST['decrement']
increment = None
print(increment, decrement)
cart.modificate(product, increment, decrement)
return redirect('cart:cart_detail')
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'crm.apps.CrmConfig',
'shop.apps.ShopConfig',
'cart.apps.CartConfig',
'orders.apps.OrdersConfig',
'coupons.apps.CouponsConfig',
'crispy_forms',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.instagram',
'allauth.socialaccount.providers.mailru',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.vk',
'allauth.socialaccount.providers.odnoklassniki',
'allauth.socialaccount.providers.yandex',
]
SITE_ID = 1
html = f'''
<!DOCTYPE html><html><head>
<meta charset="utf-8" /></head><body><table><tr>
<th>{order.first_name}</th>'
<th>Фамилия</th>
<th>Отчество</th>
</tr></table></body></html>
'''
# message += html
# mail_sent = EmailMessage(subject,
# message,
# settings.EMAIL_HOST_USER,
# ['boleev@mail.ru'])
# mail_sent.content_subtype = 'html'
mail_sent = EmailMultiAlternatives(subject,
message,
settings.EMAIL_HOST_USER,
['boleev@mail.ru'])
mail_sent.attach_alternative(html, 'text/html')
return mail_sent