GitXplorerGitXplorer
m

django-matrix-field

public
13 stars
3 forks
1 issues

Commits

List of commits on branch develop.
Unverified
a4d39cc9f40c82b1d0edd50ec8f280bb16843f89

Use travis status image for develop branch

mmfogel committed 12 years ago
Unverified
390c7665f19bf22fa320c575bdc75438ff33511d

Bump version # to 0.2

mmfogel committed 12 years ago
Unverified
b90d74d37a6618dfde004293a42b6e1666f783a0

Use string representation of datatype

mmfogel committed 12 years ago
Unverified
75428d7aab647ea71fc9eb0f82f513fe7bad4937

Update setup.py description

mmfogel committed 12 years ago
Unverified
0ed8c8a9be7d43987d2c018ddb07e1713a978169

Bump version number

mmfogel committed 12 years ago
Unverified
55732400f98652ae878d487bfc0835d5ef2b8a3e

Fill in the Readme

mmfogel committed 12 years ago

README

The README file for this repository.

django-matrix-field

.. image:: https://api.travis-ci.org/mfogel/django-matrix-field.png?branch=develop :alt: Build Status :target: https://travis-ci.org/mfogel/django-matrix-field

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

Examples

Database Field


.. code:: python

    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
    my_inst.save()        # 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
~~~~~~~~~~

.. code:: python

    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]]'


Installation
------------

Now on `pypi`__!

.. code:: sh

    pip install django-matrix-field

Running the Tests
-----------------

Using `Doug Hellman's virtualenvwrapper`__:

.. code:: sh

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


Found a Bug?
------------

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


__ http://pypi.python.org/pypi/django-matrix-field/
__ http://www.doughellmann.com/projects/virtualenvwrapper/
__ https://github.com/mfogel/django-matrix-field/