Polymorphic models based on django deferred models
Project description
ABOUT
django_deferred_polymorph is an implementation of polymorphic models for Django. Like other solutions you can just fetch the base instance from your database and get the right subclass back. This means you always can rely on having all data/methods your child class would provide.
Unlike other solutions additional data is loaded by using a slightly modified version of Django’s own deferered mechanisms. This way getting the base classes issues only one SQL query, returning the subclasses with all additional data as defered field. If you attempt to access one of the deferred fields all deferred fields are loaded (unlike for Django’s default deferred fields).
django_deferred_polymorph includes two abstract base models:
DeferredPolymorphBaseModel as the base for every deferred model
SubDeferredPolymorphBaseModel which extends DeferredPolymorphBaseModel to force userd to use a subclass
Installation
First:
pip install django_deferred_polymorph
Then add 'django_deferred_polymorph' to your INSTALLED_APPS settings.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django_deferred_polymorph-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed28e7e1e82b7e608eaaad86734fb63e364a0919e07fc8ec2c28aec5306a4396 |
|
MD5 | d64a1aea78f36d22f0726215e7b867b9 |
|
BLAKE2b-256 | ba7f49f0d39f444efa518b35b09ae1d23f1085b3a0054c327ad114110b6c710e |