Django application that provides simple templatetags to generate QR-codes
Project description
Django QR
Information
Django QR is a simple Django application that provides some templatetags that allows to include automatically QR codes on the Django site.
Installation
Once is installed from PyPI, you just need to add it to your settings as ‘qrcode’:
INSTALLED_APPS = (..., 'qrcode', ...)
Usage
Its usage is very simple. You just need to use the templatetag as follows:
{% load qr_tags %} ... {% qr_from_text "text" "size" %} or {% qr_from_mail "mail_address" "size" %}
Where:
Size is not mandatory, and defines the dimensions of the QR code as following: ‘s’ (120x120 pixels), ‘m’ (230x230 pixels), ‘l’ (350x350) or an integer with the size that you want to give to the QR-code (like 40, 80 or 500). Any other option will be ignored and will use ‘m’ as default.
qr_from_mail tag just add a simple “mailto:” at the beggining, because some qr scanners can detect that as an email address in order to send it an email.
QR-code for contact information
There’s also a templatetag to render a QR-code that allows to store some contact information, such as name, phone number, email address or our company name.
Its usage is similiar to the basics:
{% qr_from contact contact "size" %}
Where:
Size is the same as previosly
contact should be a Python dictionary (or any other hash structure) that could contain the following elements:
name - Complete name
phone_number
url - some url address, your blog or personal webpage
company
For instance, you could create a contact dictionary like the following:
contact = { 'name': 'Pablo Recio', 'phone_number': '00000000', 'email': 'foo@example.com', 'url': 'http://www.zocolab.es', 'company': 'Zocolab', }
Change service for QR generating
By default, django-qr uses Google Chart for generating the QR-code. But this can be changed with a new template. The default template qrcode/qr_tag.html contains the following:
<img src="http://chart.apis.google.com/chart?cht=qr&chs={{ size }}x{{ size }}&chl={{ text }}" />
But if you want to use some other service, like qrserver, you just need to add a new template in your templates dirs with the following code:
<img src="http://api.qrserver.com/v1/create-qr-code/?size={{ size }}x{{ size }}&data={{ text }}" />
The idea is that your qrcode/qr_tag.html contains an img tag and the call to the service that you want, mantaining the variables size and data.
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
File details
Details for the file django-qrcode-0.2.5.tar.gz
.
File metadata
- Download URL: django-qrcode-0.2.5.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22e97bbd235af46d9f015b248e6a761a5f5354741fdf06da55091fbc3777bbf1 |
|
MD5 | f91839bea6a5110927de2b0407b49be0 |
|
BLAKE2b-256 | 1c0ff2608d09ab9c908348f66c77d8c584c9e39523c4580d3c2b735656cc4d15 |