dimagi / django-cte

Common Table Expressions (CTE) for Django
Other
334 stars 46 forks source link

Add a Django Model MixIn #74

Open bernd-wechner opened 1 year ago

bernd-wechner commented 1 year ago

Replaces this syntax:

from django_cte import CTEManager

class Order(Model):
    objects = CTEManager()

with this:

from django_cte import CTEModelMixIn

class Order(Model, CTEModelMixIn):

entirely, optionally (that is the earlier syntax works too). This is simply a more canonical (IMHO) Django way of offering the same service (and has extensibility advantages - as in should the package ever need any more model enhancements, the MixIn is there to take them)

bernd-wechner commented 1 year ago

If there was only one way to do it, I'd still vote for a MixIn rather than overriding an attribute, as it strikes me as both more Django and is more extensible. Either way, it's a small value add.