checkout/src/purchase/layout.py

16 lines
493 B
Python
Raw Normal View History

2022-04-24 18:59:04 +02:00
from crispy_forms.layout import Field
class BasketItemField(Field):
template = "purchase/snippets/basket_item.html"
2022-04-24 18:59:04 +02:00
def __init__(self, *args, product, **kwargs):
super().__init__(*args, **kwargs)
self.product = product
def render(self, *args, **kwargs):
extra_context = kwargs.get("extra_context", {})
extra_context.update({"product": self.product})
kwargs["extra_context"] = extra_context
return super().render(*args, **kwargs)