Data model

Data in Shuup is stored into database using regular Django models and it is accessed with Django’s normal query API. See shuup.core.models for list of models in Shuup Core.

Extending models

Non-polymorphic models

Basic models (like Product, Category or Order) cannot be replaced. To extend them, create a new model for your extensions and link that to the original model with a OneToOneField.

For example:

from django.core import models
from shuup.core import models as shuup_models

class MyProduct(models.Model):
    product = models.OneToOneField(shuup_models.Product)

    # fields of the extension...
    my_field = models.CharField(max_length=10)


Check multi-table-inheritance for extending models


Even though basic models cannot be replaced, it is possible to replace the User model. See specifying-custom-user-model.

Polymorphic models

Polymorphic models (like Contact) can be extended by inheritance. The polymorphic base class has a model manager that makes sure that the returned objects are correct type. For example, when getting all Contacts with a query like Contact.objects.all(), the returned QuerySet may have instances of PersonContact, CompanyContact and your custom class.

See django-polymorphic’s documentation for details.