Skip to main content

Provides a simple way to handle jSignature jQuery plugin through a django form.

Project description

A simple way to use jSignature jQuery plugin in your Django projects.

It provides:

  • A form field and a form widget to handle jquery plugin through a Django form;

  • A model field to store a captured signature;

  • A mixin adding two fields (signature / signature_date) in any of your Django models.

https://travis-ci.org/fle/django-jsignature.png?branch=master https://coveralls.io/repos/fle/django-jsignature/badge.png https://gitlab.com/adremides/django_jsignature3/blob/master/screen.png

INSTALL

pip install django_jsignature3

USAGE

  • Add jsignature to your INSTALLED_APPS:

# settings.py
INSTALLED_APPS = (
...
'jsignature',
)

In a Form

  • Use provided form field and widget:

# forms.py
from django import forms
from jsignature.forms import JSignatureField

class SignatureForm(forms.Form):
    signature = JSignatureField()
  • In your template

{{ form.media }}
<form action="." method="POST">
    {% for field in form %}
        {{ field.label_tag }}
        {{ field }}
    {% endfor %}
    <input type="submit" value="Save"/>
    {% csrf_token %}
</form>
  • Render image after form validation:

# views.py
from jsignature.utils import draw_signature
from myapp.forms import SignatureForm

def my_view(request):
    form = SignatureForm(request.POST or None)
    if form.is_valid():
        signature = form.cleaned_data.get('signature')
        if signature:
            # as an image
            signature_picture = draw_signature(signature)
            # or as a file
            signature_file_path = draw_signature(signature, as_file=True)

In Django Admin

# models.py
from jsignature.fields import JSignatureField


class Firma(models.Model):
    firma = JSignatureField(blank=True, null=True)

If you wan to store signatures, provided mixin gives a signature and a signature_date that update themselves:

from django.db import models
from jsignature.mixins import JSignatureFieldsMixin

class JSignatureModel(JSignatureFieldsMixin):
    name = models.CharField()

CUSTOMIZATION

JSignature plugin options are available in python:

  • Globally, in your settings:

# settings.py
JSIGNATURE_WIDTH = 500
JSIGNATURE_HEIGHT = 200
  • Specifically, in your form:

# forms.py
from jsignature.forms import JSignatureField
from jsignature.widgets import JSignatureWidget

JSignatureField(widget=JSignatureWidget(jsignature_attrs={'color': '#CCC'}))

Available settings are:

  • JSIGNATURE_WIDTH (width)

  • JSIGNATURE_HEIGHT (height)

  • JSIGNATURE_COLOR (color)

  • JSIGNATURE_BACKGROUND_COLOR (background-color)

  • JSIGNATURE_DECOR_COLOR (decor-color)

  • JSIGNATURE_LINE_WIDTH (lineWidth)

  • JSIGNATURE_UNDO_BUTTON (UndoButton)

  • JSIGNATURE_RESET_BUTTON (ResetButton)

AUTHORS

makinacom

MANTAINERS

Project details


Download files

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

Source Distribution

django_jsignature3-0.9.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

django_jsignature3-0.9.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file django_jsignature3-0.9.0.tar.gz.

File metadata

  • Download URL: django_jsignature3-0.9.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.0 Windows/10

File hashes

Hashes for django_jsignature3-0.9.0.tar.gz
Algorithm Hash digest
SHA256 5887900a3457dda2a9acb3d1e9281caafaf0cf6f6d18f681b8d39539d927f39f
MD5 7003ed9b9acec9fe567181cb28e1ef12
BLAKE2b-256 ad67c21a030e718ebbce939838db1d15e3415ae24cebafbf8a407bf183884083

See more details on using hashes here.

File details

Details for the file django_jsignature3-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_jsignature3-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f60c2e6117d213c05600afef9dc5b87ed082cc75ae0422c829df79ba78c338e
MD5 66aa1fb737719c29d28d9f5310ad68fc
BLAKE2b-256 65bb187a51ebd51877f45aca3f7d2b0e2e639484ea9e22c448e21521225bf402

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page