Login

Snippets by julkiewicz

Snippet List

(Almost) Single table polymorphism in Django

An emulation of "table per hierarchy" a.k.a. "single table inheritance" in Django. The base class must hold all the fields. It's subclasses are not allowed to contain any additional fields and optimally they should be proxies. They however may provide additional methods to operate on the declared field. The presented solution supports implicit inheritance, even across ForeignKeys, and ManyToManyFields. No additional database hits are imposed.

  • django
  • django-models
  • table-per-hierarchy
  • single-table-polymorphism
  • polymorphism
Read More

julkiewicz has posted 1 snippet.