Creating a product in django SHOP is really easy, but requires you to write python code.
The first step for you is to create a model to use as a product. We will create an example Book model together:
from shop.models.productmodel import Product
from django.db import models
class Book(Product):
isbn = models.CharField(max_length=255)
The following fields are already defined in the Product superclass:
Like other objects in Django, you will need to create a template to display your model’s contents to the world. By default, your Product subclass will use the “shop/product_detail.html” template as a fallback, but will use your own template if you follow Django’s naming conventions: “appname/book_detail.html”.
That’s all there is to it :)
Your product should behave like a normal Django model in all circumstances. You should register it to admin (and create an admin class for it) like a normal model.
Code wise, the following options are possible to retrieve your newly created model:
# This gets your model's instance the normal way, you get both your model's
# fields and the Product fields
o = MyProduct.objects.get(pk=...)
# This is also possible - You retrieve a MyProduct instance, using the
# Product manager
o = Product.objects.get(pk=...)
Note
This is possible thanks to the terrific django_polymorphic dependency
By design, django SHOP does not include an out of the box solution to handling product variations (colors, sizes...), in order to let implementors create their own unrestricted.
If you want such a pre-made solution for simple cases, we suggest you take a look at the shop_simplevariations “add-on” application, located at: