Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Django app providing database and form fields for matrices (arrays of arrays).

Project Description

A Django app providing database and form fields for matrices (arrays of arrays).


Database Field

from django.db import models
from matrix_field import MatrixField

class MyModel(models.Model):
    matrix1 = MatrixField(datatype='float', dimensions=(3, 2))
    matrix2 = MatrixField(datatype='str', dimensions=(2,))

my_inst = MyModel(
    matrix1=[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]],
    matrix2=['a list', 'of strings'],
my_inst.full_clean()  # validates datatype, dimensions        # values stored in DB as json

m1 = my_inst.matrix1  # values retrieved as matrices
repr(m1)              # '[[5.1, -1.2], [4.2, 0.0], [3.14, 2.71]]'

Form Field

import json
from django import forms
from matrix_field import MatrixFormField

class MyForm(forms.Form):
    matrix = MatrixFormField(datatype='int', dimensions=(2, 1))

my_form = MyForm({
    'matrix': json.dumps([[2], [1]]),  # assignment of json representation
my_form.full_clean()                   # validates datatype, dimensions

m = my_form.cleaned_data['matrix']  # values retrieved as matrices
repr(m)                             # '[[2], [1]]'


Now on pypi!

pip install django-matrix-field

Running the Tests

Using Doug Hellman’s virtualenvwrapper:

pip install django-matrix-field
export DJANGO_SETTINGS_MODULE=matrix_field.test_settings test matrix_field

Found a Bug?

To file a bug or submit a patch, please head over to django-matrix-field on github.

Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-matrix-field-0.2.tar.gz (6.7 kB) Copy SHA256 Checksum SHA256 Source Dec 28, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting