12👍
You might want to look into django-dbarray on github. It adds support for postgresql array fields.
I haven’t used it before, but it looks like you just need to do:
from django.db import model
import dbarray
class ProfilingTestRun(models.Model):
function = models.CharField(max_length=64)
runtimes = dbarray.FloatArrayField()
4👍
One of the other nice options is http://django-orm.readthedocs.org/ — a library that adds bindings to many native postgres types.
Main drawback of django-orm
is that as of today it has no working support for south
.
- How to remove these '"' in django template
- Django raises MultiValueDictKeyError in File Upload
- Appropriate choice of authentication class for python REST API used by web app
4👍
djorm-ext-pgarray also offer queries
http://www.niwi.be/2012/10/07/postgresql-array-fields-with-django/
- How can I easily convert a Django app from mySQL to PostgreSQL?
- Django model: Filtering by user, always
- DISTINCT ON fields is not supported by this database backend
- If I send a python 'Signal' object from a function, what should the "sender" argument be?
3👍
Native support for PostgreSQL specific model fields is coming soon to Django (in the django.contrib.postgres.fields module):
- https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#arrayfield
- https://github.com/django/django/pull/2485 : The corresponding pull request
- Django fixtures not accepting YAML?
- Django templates – can I set a variable to be used in a parent template?
2👍
Since Django 1.8 there is a django.contrib.postgress module that adds support to array fields among other PostgreSQL data types.
For example you can do something like this:
from django.contrib.postgres.fields import ArrayField
from django.db import models
class GoGame(models.Model):
board = ArrayField(ArrayField(models.IntegerField(),size=19),size=19)
- Can't pip install mysql-python
- Django queryset __contains case sensitive?
- How to display month name by number?
- Tastypie Negation Filter
- Get a list of python packages used by a Django Project
1👍
you have to subclass model.Field
and write input and output methods.
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#custom-database-types