Skip to main content

django-matrix-field

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

Examples

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

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

Found a Bug?

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

Metadata

Release files for django-matrix-field 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-matrix-field 0.3
File Size Uploaded Provenance Actions
django_matrix_field-0.3.tar.gz 6.8 kB Without provenance Details for django_matrix_field-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-matrix-field 0.3
File Interpreter ABI Platform Actions
django_matrix_field-0.3-py3-none-any.whl Python 3 none any Details for django_matrix_field-0.3-py3-none-any.whl

Total release size: 14.8 kB

Release files / django_matrix_field-0.3.tar.gz

Download URL django_matrix_field-0.3.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c1757a2592399053286d2ea18f2bc204a2c011efd445b1d14e9a20b690e42c47
BLAKE2b-256 checksum
How to use checksums
5aa49a74e9227cf7d6645defbd0f1455f2c6823010edb5bfca0dd900473f9c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / django_matrix_field-0.3-py3-none-any.whl

Download URL django_matrix_field-0.3-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5a32d9c797991ef7bd6d551fa9e7769573e8db59ac74244702460576f3412fc
BLAKE2b-256 checksum
How to use checksums
3ecfe6102789802631071cd0b268ab2745c90513d3997e661ea447f145c46538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Security for django-matrix-field 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page