[Django]-Django design patterns for overriding models

1👍

Did you look at the code from other projects with a similar approach?
Not sure if this way covers your needs, but imo the code of django-shop is worth to look at.

This framework provides the basic logic, allowing you to provide custom logic where needed.

customize via models

eg see the productmodel.py

#==============================================================================
# Extensibility
#==============================================================================
PRODUCT_MODEL = getattr(settings, 'SHOP_PRODUCT_MODEL',
    'shop.models.defaults.product.Product')
Product = load_class(PRODUCT_MODEL, 'SHOP_PRODUCT_MODEL')

customize via logic/urls

eg see the shop’s simplevariation-plugin
It extends the cart-logic, so it hooks in via urlpattern:

(r'^shop/cart/', include(simplevariations_urls)),
(r'^shop/', include(shop_urls)),

and extends the views:

from shop.views.cart import CartDetails

class SimplevariationCartDetails(CartDetails):
    """Cart view that answers GET and POSTS request."""
...

The framework provides several points to hook-in, the simplevariation-plugin mentionned above additionally provides a cart-modifier:

SHOP_CART_MODIFIERS = [
    ...
    'shop_simplevariations.cart_modifier.ProductOptionsModifier',
    ...
]

I worry that this explanation is not very understandable, it is difficult to briefly summarize this concept. But take a look at the django-shop project and some of its extensions: ecosystem

Leave a comment