djangosnippets.org: Latest snippets tagged with 'polymorphic'https://djangosnippets.org/tags/polymorphic/2010-10-03T10:01:25.101574-05:00Polymorphic inheritance ala SQLAlchemy
2010-10-03T10:01:25.101574-05:00gsakkishttps://djangosnippets.org/snippets/2216/<p>This is a different take on polymorphic inheritance, inspired by SQLAlchemy's approach to the problem.</p>
<p>The common Django approach (e.g. snippets 1031 & 1034, <a href="http://github.com/bconstantin/django_polymorphic">django_polymorphic</a>) is to use a foreign key to <code>ContentType</code> on the parent model and override <code>save()</code> to set the right content type automatically. That works …</p>
Freely redistributable