Answer the question
In order to leave comments, you need to log in
How to save size to cart in django-oscar?
Hello, I'm trying to customize saving a product to the cart.
First I changed the model
from oscar.apps.basket.abstract_models import AbstractLine
class Line(AbstractLine):
size = models.IntegerField(default=0)
<form id="add_to_basket_form" action="{% url 'basket:add' pk=product.pk %}" method="post" class="add-to-basket">
{% csrf_token %}
{% include "partials/form_fields.html" with form=basket_form %}
{{basket_form.size}}
<button type="submit" class="btn btn-lg btn-primary btn-add-to-basket" value="{% trans "Add to basket" %}" data-loading-text="{% trans 'Adding...' %}">{% trans "Add to basket" %}</button>
</form>
from oscar.apps.basket.forms import AddToBasketForm,
class AddToBasketForm(AddToBasketForm):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
size = forms.CharField()
class Meta:
fields = '__all__'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question