Django product is not adding to cart

I am trying to add cart to my website using Django I have some problems: I cant add product to my cart and for some reason I do not have choice of quantity of this product

this is my page

that`s what i need

this is my cart

path('cart/', cart_detail, name='cart_detail'),
path('cart/add/<int:post_id>/', cart_add, name='cart_add'),
path('cart/remove/<int:post_id>/', cart_remove, name='cart_remove'),

def cart_add(request, post_id):
    cart = Cart(request)
    post = get_object_or_404(Posts, id=post_id)
    form = CartAddProductForm(request.POST)
    if form.is_valid():
        cd = form.cleaned_data
    return redirect('cart_detail')

def cart_remove(request, post_id):
    cart = Cart(request)
    post = get_object_or_404(Posts, id=post_id)
    return redirect('cart_detail')

def cart_detail(request):
    cart = Cart(request)
    return render(request, 'store/detail.html', {'cart': cart})

def product_detail(request, post_id, slug):
    product = get_object_or_404(Posts,
    cart_product_form = CartAddProductForm()
    return render(request, 'store/detail.html', {'product': product,
                                                        'cart_product_form': cart_product_form})

my form in html file

<form action="{% url  'cart_add' %}" method="post">
    {{ cart_product_form }}
    {% csrf_token %}
    <input type="submit" value="Add to cart">

from decimal import Decimal
from django.conf import settings
from .models import Posts

class Cart(object):

    def __init__(self, request):
        self.session = request.session
        cart = self.session.get(settings.CART_SESSION_ID)
        if not cart:
            cart = self.session[settings.CART_SESSION_ID] = {}
        self.cart = cart

    def add(self, post, quantity=1, update_quantity=False):
        post_id = str(
        if post_id not in self.cart:
            self.cart[post_id] = {'quantity': 0,
                                     'price': str(post.price)}
        if update_quantity:
            self.cart[post_id]['quantity'] = quantity
            self.cart[post_id]['quantity'] += quantity

    def save(self):
        self.session[settings.CART_SESSION_ID] = self.cart
        self.session.modified = True

    def remove(self, post):
        post_id = str(
        if post_id in self.cart:
            del self.cart[post_id]

    def __iter__(self):
        post_ids = self.cart.keys()
        posts = Posts.objects.filter(id__in=post_ids)
        for post in posts:
            self.cart[str(]['post'] = post

        for item in self.cart.values():
            item['price'] = Decimal(item['price'])
            item['total_price'] = item['price'] * item['quantity']
            yield item

    def __len__(self):
        return sum(item['quantity'] for item in self.cart.values())

    def get_total_price(self):

        return sum(Decimal(item['price']) * item['quantity'] for item in

    def clear(self):
        del self.session[settings.CART_SESSION_ID]
        self.session.modified = True

class CartAddProductForm(forms.Form):
    quantity = forms.TypedChoiceField(choices=POST_QUANTITY_CHOICES, coerce=int)
    update = forms.BooleanField(required=False, initial=False, widget=forms.HiddenInput)

I have only button "add to cart" which is not working without choice of quantity

Back to Top