Login

Filter to generate QR codes

Author:
javinievas
Posted:
July 30, 2010
Language:
Python
Version:
Not specified
Tags:
filter templatetag templatefilter barcode qr
Score:
1 (after 1 ratings)

You can convert any string to a QR code image as easy as use a simple filter, thanks to google charts api.

Common use: <img src="{{object.attribute_to_encode|qr:"120x130"}}" />

This will create a 120(width) x 130(heiht) image with the value of the attribute_to_encode encoded in a QR coded image.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from django import template

register = template.Library()

@register.filter
def qr(value,size="150x150"):
    """
        Usage:
        <img src="{{object.code|qr:"120x130"}}" />
    """
    return "http://chart.apis.google.com/chart?chs=%s&cht=qr&chl=%s&choe=UTF-8&chld=H|0" % (size, value)

More like this

  1. Simple "html email with images" sender by andres_torres_marroquin 4 years, 2 months ago
  2. E-mail quoting filters and tags by ChipX86 7 years, 11 months ago
  3. [UPDATE]Filter to resize a ImageField on demand by rafacdb 6 years, 9 months ago
  4. Wiki-like markup for sub templates by luckystarr 7 years, 8 months ago
  5. Type checking templatetag filters by marcorogers 5 years, 3 months ago

Comments

Please login first before commenting.