Message info
 
To:django-users@googlegroups.com From:Craig de Stigter Subject:django-typed-models - sane single-table model inheritance Date:Sun, 19 Feb 2012 13:12:57 -0800 (PST)
 

In May last year I posted this topic on django-developers.

We wanted a way to do proxy-model inheritance, while preserving the type of each object when it goes in and out of the database.

Unable to find anything that did what I wanted, I wrote my own! It was basically finished by June last year but I finally open-sourced it:

https://github.com/craigds/django-typed-models

Basically you can just define a base model, with database fields, and then inherit from it as much as you want. The inherited models all become proxy models - they only define in-python behavior, they can't define database fields.

Everything gets stored in one table, and retrieving objects from the database will result in them having the correct model class. A single queryset of a superclass might result in the retrieval of multiple types of subclasses, all in one query.

See the readme on that github link for an example. Please let me know what you think! And file issues if you have some.

Cheers

Craig de Stigter
Koordinates Ltd

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Ff9H0nAZHbAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.