django的qrcode过滤器和视图
django-qrcode2的Python项目详细描述
QRcode滤波
快速启动
安装:
pip install django_qrcode2
将“qrcode2”添加到已安装的应用程序设置中,如下所示:
INSTALLED_APPS = [ ... 'qrcode2', ]
[可选]在项目url.py中包含qrcode2 urlconf,如下所示:
url(r'^qrcode/', include('qrcode2.urls')),
无需迁移
将筛选器添加到模板,如下所示:
{% load qrcode2 %} <!-- if an view with name 'qrcode' is provided, 'src' will be an url, otherwise it's an base64 data blob --> <img src="{{ 'some text' | qrcode_src }}"> <!-- insert an <img> with template inclusion --> {% include 'qrcode2/img.html' with text='hello' %}