Skip to main content

SignCanvasField

Project description

Django Canvas Field

这是一个 Python 模块,为 Django 提供手写签名字段,以及手写签名的网页控件,感谢 jSignatrue 项目为本模块提供支持。

  1. 安装并注册模块

    # pip install django-canvas-field
    # File: settings.py
    INSTALLED_APPS = [
    	"canvas",
    ]
    
  2. 在模型中使用

    from canvas.fields import SignCanvasField
    
    class Simple(Model):
        name = CharField(max_length=20, unique=True)
        sign = SignCanvasField(null=True, blank=True)
    
  3. 使用签名控件

    from django import forms
    from canvas.widgets import SignCanvasWidget
    
    from .models import Simple
    
    class SimpleForm(forms.ModelForm):
        class Meta:
            model = Simple
            widgets = {
                'sign': SignCanvasWidget()
            }
    

SignCanvasWidgetdjango.forms.widgets.Textarea 的子类,使用自定义的模板 sign_canvas.htmlSignCanvasFielddjango.db.models.TextField 的子类,表单字段指向 SignCanvasWidget

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-canvas-field-1.0.0.tar.gz (54.0 kB view hashes)

Uploaded Source

Built Distribution

django_canvas_field-1.0.0-py3-none-any.whl (56.5 kB view hashes)

Uploaded Python 3

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