Django_matplotlib is a reusable Django app for embedding matplotlib figures into Django driven websites. It can be easily integrated with Django admin app and used in templates via forms.
Documentation: http://django-matplotlib.readthedocs.org/
Django 1.11+, <3.0; Python 3.5+, <3.8.
- Clone git repository to place where Django can find it:
pip install django-matplotlib
- Add "django_matplotlib" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'django_matplotlib',
...
]
- Use MatplotlibField in your models.py, e.g.:
from django.db import models
from django_matplotlib.fields import MatplotlibFigureField
class MyModelWithFigure(models.Model):
# ... other fields
# figures.py should be in the same directory where models.py is placed.
# see ./django_matplotlib/figures.py for example.
fig = MatplotlibFigureField(figure='test_figure', verbose_name='figure',
silent=True)
# ... other fields
- Generate and apply migrations.
Note
It is assumed that you have Django installed already. Additionally, you will need to install matplotlib to use MatplotlibFigureField in your models.
Dmitry E. Kislov
E-mail: kislov@easydan.com