Hello! First of all, I wanted to thank all the contributors of oscar for their hard work. My first try to roll an e-commerece solution ran up against difficulties -- it's nigh impossible to produce a sufficiently mature codebase singlehandedly.
I am currently working on modifying Oscar for a situation where customers
order food for takeout, and have the ability to choose flavors,
seasonings, side dishes, etc.
To implement this feature I want to 'reattach' Product Attributes from ProductClasses
to Products and let the customer choose the specifics in the front-end (catalogue).
Here I attempt to modify ProductAttribute model to point to Product instead of ProductClass:
in models.py:
import ...
from oscar.apps.catalogue.abstract_models import AbstractProductAttribute, AbstractProduct
class ProductAttribute(AbstractProductAttribute):
product = models.ForeignKey(
'catalogue.Product',
blank=True,
on_delete=models.CASCADE,
related_name='attributes',
null=True,
verbose_name=_("Product type"))
..........
..........
from oscar.apps.catalogue.models import * # noqa
and use the new model to produce a formset:
in forms.py:
from myapp.catalogue.models import Product, ProductAttribute
from myapp.catalogue.forms import ProductAttributesForm
ProductAttributesFormSet = inlineformset_factory(Product,
ProductAttribute,
form=ProductAttributesFor,
extra=3)
I don't have a lot of experience with Django, so it's unclear to me wether this is a namespacing issue or faulty data modeling.
As always, all feedback is appreciated.
Wishing a great day, Al