You can create a QRcode using the python pygooglechart wrapper for Google chart API. Here i used the wrapper to generate the QRcode as a django app but right now I wont go into the specifics of how to create a django app, maybe will do later,
but this is the view i made for the qr app, i passed the form results to the QRChart and formatted the results in a Vcard format and its then rendered to the page.
You can see the script in action here
test it using an QR android/iphone app
Now the Views….
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from django.template.loader import get_template from django.template import Template, Context from django.http import HttpResponse, Http404 from django.shortcuts import render_to_response from django.core.mail import send_mail from django.http import HttpResponseRedirect from cacoos_com.qr.qr_form import QrForm from pygooglechart import QRChart def qr(request): if request.method == 'POST': qform = QrForm(request.POST) if qform.is_valid(): qc = qform.cleaned_data chart = QRChart(300,300) mecard = "BEGIN:VCARD"+"\n"+"VERSION:3.0 \n"+"FN:"+qc['name']+"\n"+"TEL;type=CELL:"+qc['phone']+"\n"+"EMAIL;type=INTERNET;type=WORK;type=pref:"+qc['email']+"\n"+"URL;type=pref:"+qc['url']+"\n" chart.add_data(mecard) chart.set_ec('H', 0) chart.download('/usr/share/pyshared/django/contrib/admin/media/qr-hello.png') return render_to_response('qr_results.html', {'url': qc['url'] }) else: qform = QrForm(initial={'url': 'type your url here'}) return render_to_response('qr_form.html', {'form': qform}) |
You can use the following template to generate a Vcard, quite handy…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | BEGIN:VCARD VERSION:3.0 N:Doe;John;;; FN:John Doe ORG:Example.com Inc.; TITLE:Imaginary test person EMAIL;type=INTERNET;type=WORK;type=pref:johnDoe@example.org TEL;type=WORK;type=pref:+1 617 555 1212 TEL;type=CELL:+1 781 555 1212 TEL;type=HOME:+1 202 555 1212 TEL;type=WORK:+1 (617) 555-1234 item1.ADR;type=WORK:;;2 Example Avenue;Anytown;NY;01111;USA item1.X-ABADR:us item2.ADR;type=HOME;type=pref:;;3 Acacia Avenue;Newtown;MA;02222;USA item2.X-ABADR:us NOTE:John Doe has a long and varied history\, being documented on more police files that anyone else. Reports of his death are alas numerous. item3.URL;type=pref:http\://www.example/com/doe item3.X-ABLabel:_$!<HomePage>!$_ item4.URL:http\://www.example.com/Joe/foaf.df item4.X-ABLabel:FOAF item5.X-ABRELATEDNAMES;type=pref:Jane Doe item5.X-ABLabel:_$!<Friend>!$_ CATEGORIES:Work,Test group X-ABUID:5AD380FD-B2DE-4261-BA99-DE1D1DB52FBE\:ABPerson END:VCARD |