GithubHelp home page GithubHelp logo

django-pgfields's Introduction

django-pgfields

Implementation of various postgres-specfic pieces of functionality for django. Current features include: array types, hstore types, a uuid field, an enum field, a view model mixin, and a materialized view model mixin.

django-pgfields will take care of all pre-use database operations, such as 'CREATE TYPE' for the ENUMField, 'CREATE VIEW' for the View mixin, and creation of the view and storage table for the materialized view mixin.

Usage

Field Types

For all field types, simply:

import pgfields

class Student(models.Model):
    id = pgfields.UUIDField()
    name = models.CharField(max_length=256)
    grades = pgfields.CharArray()
    grade_number_mapping = pgfields.DictionaryField()

View Types

In order to utilize the View and MatView model mixins, you'll have to add 'pgfields' to INSTALLED_APPS. Then you can define your view this way:

import pgfields

class MyView(models.Model, pgfields.View):
    sql = "SELECT list,of,stuff FROM tablename ORDER BY date"

This will create a postgres view called <modelname>_myview. Running syncdb (or migrate, if you're using South to manage this model) will take care of the creation of the view utilizing the query provided in the sql variable.

Requirements

psycopg2

This module has only been tested against django 1.4.1

django-pgfields's People

Contributors

spuriousdata avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.