In May last year I posted this 
topic<https://groups.google.com/d/topic/django-developers/1LA98LjNz-g/discussion>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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to