1👍
Ok, I’ve digged a little bit further and found this nice passage:
https://github.com/bconstantin/django_polymorphic/blob/master/DOCS.rst#performance-considerations
So happily this library does something reasonably sane. That’s good to know.
2👍
Django-Typed-Models is an alternative to Django-Polymorphic which takes a simple & clean approach to solving the single table inheritance issue. It works off a ‘type’ attribute which is added to your model. When you save it, the class is persisted into the ‘type’ attribute. At query time, the attribute is used to set the class of the resulting object.
It does what you expect query-wise (every object returned from a queryset is the downcasted class) without needing special syntax or the scary volume of code associated with Django-Polymorphic. And no extra database queries.
- [Django]-Django: The value of the id field is coming None
- [Django]-How long does it take for a Djoser access token until expire?
- [Django]-How to fix "fatal error: Carbon/Carbon.h: No such file or directory", when trying to deploy to Heroku – (Django)
1👍
In Django inherited models are internally represented through an OneToOneField
. If you are using select_related()
in a query Django will follow a one to one relation forwards and backwards to include the referenced table with a join; so you wouldn’t need to hit the database twice if you are using select_related
.
- [Django]-Testing Django view requiring user authentication with Factory Boy
- [Django]-Why does Paypal retry IPN when using django-paypal
- [Django]-Django, Borg pattern, API calls, caching results
- [Django]-ImportError No module named blog