A Django app to define Postgres Views as Models
Project description
Viewed Models is a simple way to add PostGres “views” which look to Django just like Models. This lets us go outside the Django ORM to create views or materialized views to harness the power of PostGreSQL without losing the power to access that data using the ORM.
- Usage:
A model which uses this framework should inherit from ViewedModel
The model requires an “sql” method which returns the sql required to create view
The model also requires a “dependencies” attribute. These are useful in generating table names within the SQL statement as well as dependency resolution.
- The model also requires fields specified in the standard Django way. Foreign keys should work fine
Foreign Keys: For ForeignKey(myApp.MyModel') we need to have a field ‘mymodel_id’ returned from the SQL.
Every Django model (including these ViewedModels) requires an ‘id’ field. We can fake this by including row_number() OVER () AS id somewhere in our SELECT statement.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for django_viewedmodels-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4783f7fcc436148da2c2dd82fe8b6d69fa176d81b802574e8bd8c4098cbed81 |
|
MD5 | 3fa112a1b2c6a3f1a20fb9b4af89184d |
|
BLAKE2b-256 | f28cf421c082359d7f3120ceb7a68eaa3be15e7e5d7db2be917f7d90fca65998 |
Hashes for django_viewedmodels-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5413ad48026e6ac035f2ca79e77f1ea65456c1f4474173270351930e6b40eff |
|
MD5 | e0ebef688afcbd3da78c0402c9618bd1 |
|
BLAKE2b-256 | 40abf1d34820dc0dd82ca8d932fbeab12a12f2f13d9f5eac08e0d930ebb31b44 |
Hashes for django_viewedmodels-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d0f2223aec18a9692b647548c8dcd157a58730ffa63229f0372bff34aa7653 |
|
MD5 | 8ac96fa1c0d53680b3332329eeaaa580 |
|
BLAKE2b-256 | 3c701d8c06026d335d4ffcdb4c841035bd09dfb9bb02b91d200389cd7c55868b |