Model Inheritance Hits QuerySet-Refactor Branch
Model inheritance will soon be a reality in Django. While some from the hardcore OOP camp may give a half-reluctant nod of appreciation, this is reason to rejoice for anyone rooting for Django to continue to vie for the hearts of contemporary web platform evangelists. While it has always been possible to tweak models to your liking via Django hooks or plain Python introspection, these solutions often felt kludgy from a maintenance/organization perspective. Keeping in mind that relational database architecture and object oriented programming techniques don't always unite in a clean way, us application programmers can feel relieved when our framework of choice feels pretty natural most of the time dealing with the data tier. The introduction of model inheritance to Django obviates the need to resort to hooks or metaclasses for many common situations and should quell concerns for developers coming in from other OOP-heavy frameworks.
Without being sure what the time frame for acceptance to trunk is for the qs-refactor branch, I would approach this announcement as a learning opportunity. The machinery of object inheritance can be tricky and when married to OR/M I would expect there will be some kinks to work out. I wouldn't plan on switching your Django tree to qs-refactor anytime soon just because of this feature. Like anything in programming it won't be a panacea - trade-offs are always involved.
There was a question on the user group about whether this feature would render generic relationships irrelevant. Model inheritance actually complements generic relationships nicely, rather than making them unnecessary:
Model inheritance is quite different from generic relations. In fact, they're opposites. Generic relations provide a way to push from the general to the specific in situations where you're driving things from the general class (the one containing the generic relation). Model inheritance provides a way to pull the more general parent classes into a more specific child class where you'll normally be working with the child.
-Malcom Tredinnick
You can read the documentation here.
<< Back to Unbracketed Home Post a Comment Now
Post a comment
- Markdown syntax is allowed. HTML tags will be stripped.
- CodeHilite NOT supported at this time but coming soon...
- Constructive statements and good attitudes are encouraged - being kind is better than being right


