{"repo":"mypebble/django-pgviews","free":true,"listed":false,"github":"https://github.com/mypebble/django-pgviews","clone":"git clone https://github.com/mypebble/django-pgviews.git","description":"Fork of django-postgres that focuses on maintaining and improving support for Postgres SQL Views.","language":"Python","stars":202,"topics":["sql-views","django","postgres","python","pg-views","sql"],"license":"Unlicense","category":"databases-storage","readme_excerpt":"SQL Views for Postgres Adds first-class support for [PostgreSQL Views][pg-views] in the Django ORM [pg-views]: http://www.postgresql.org/docs/9.1/static/sql-createview.html Installation Install via pip: pip install django-pgviews Add to installed applications in settings.py: Examples NOTE It is important that we include the managed = False in the Meta so Django 1.7 migrations don't attempt to create DB tables for this view. The SQL produced by this might look like: To create all your views, run python manage.py sync pgviews You can also specify field names, which will map onto fields in your View: Usage To map onto a View, simply extend pg views.view.View , assign SQL to the sql argument and define a db table . You must always set managed = False on the Meta class. Views can be created in a number of ways: 1. Define fields to map onto the VIEW output 2. Define a projection that describes the VIEW fields Define Fields Define the fields as you would with any Django Model: Define Projection django-pgviews can take a projection to figure out what fields it needs to map onto for a view. To use this, set the projection attribute: This will take all fields on myapp.Customer and apply them to PreferredCustomer Features Updating Views Sometimes your models change and you need your Database Views to reflect the new data. Updating the View logic is as simple as modifying the underlying SQL and running: This will forcibly update any views that conflict with your new SQL. Dependencies You","default_branch":null,"files":null,"tree":[],"storefront":"/r/mypebble","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mypebble/django-pgviews/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}