Django ORM field for Postgres array types.
Project description
A Django model field that stores lists of values. Implemented using the PostgreSQL array type.
==========
Usage
==========
Note that this field currently works only on Postgres/psycopg2. Requires Django >= 1.2.
Four field types are defined in the ``dbarray`` module::
from django.db import models
import dbarray
class Foo(models.Model):
numlist = dbarray.IntegerArrayField()
floatlist = dbarray.FloatArrayField(null=True)
textlist = dbarray.TextArrayField(
help_text="Fields take the same arguments as their corresponding Django fields.")
charlist = dbarray.CharArrayField(max_length=5)
==========
Custom fields
==========
To define an array type based on a field other than Integer, Float, Text, or Char::
import dbarray
class FooArrayField(dbarray.ArrayFieldBase, FooField):
__metaclass__ = dbarray.ArrayFieldMetaclass
This may or may not work depending on a few factors; you might, for example, need
to override the db_type method to make it add ``[]`` to right spot in the column
type used in generated SQL.
==========
Usage
==========
Note that this field currently works only on Postgres/psycopg2. Requires Django >= 1.2.
Four field types are defined in the ``dbarray`` module::
from django.db import models
import dbarray
class Foo(models.Model):
numlist = dbarray.IntegerArrayField()
floatlist = dbarray.FloatArrayField(null=True)
textlist = dbarray.TextArrayField(
help_text="Fields take the same arguments as their corresponding Django fields.")
charlist = dbarray.CharArrayField(max_length=5)
==========
Custom fields
==========
To define an array type based on a field other than Integer, Float, Text, or Char::
import dbarray
class FooArrayField(dbarray.ArrayFieldBase, FooField):
__metaclass__ = dbarray.ArrayFieldMetaclass
This may or may not work depending on a few factors; you might, for example, need
to override the db_type method to make it add ``[]`` to right spot in the column
type used in generated SQL.
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
django-dbarray-0.0.1.tar.gz
(2.6 kB
view details)
File details
Details for the file django-dbarray-0.0.1.tar.gz
.
File metadata
- Download URL: django-dbarray-0.0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 094e6725df42d0a5ed3aa98cd721e0540ac15540db7f804cd558ec970d20690f |
|
MD5 | 33fd8c856f676878e536ba721707a9d3 |
|
BLAKE2b-256 | 7b7ec4b5db9626bf6fdbf1c994a80b7d6194f7ddc9f460c888ee9c79623550ab |