django-qr-code

4.2.0 · active · verified Fri Apr 17

An application that provides tools for displaying QR codes on your Django site. It supports generation of QR codes as SVG, PNG, or Base64 embedded images, via both Django template tags and a Python API. The current version, 4.2.0, released in May 2025, actively tracks Django and Python releases, ensuring compatibility with the latest versions.

Common errors

Warnings

Install

Imports

Quickstart

To quickly integrate `django-qr-code`, first add it to your `INSTALLED_APPS` and include its URL patterns in your project's `urls.py`. Then, use the `{% qr_from_text %}` template tag in any Django template to generate and display QR codes. Ensure `Pillow` is installed if generating PNG images.

# myproject/settings.py
INSTALLED_APPS = [
    # ... other apps
    'qr_code',
]

# myproject/urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('qr_code/', include('qr_code.urls', namespace='qr_code')), # Add this line
    # ... other paths
]

# myapp/templates/myapp/my_template.html
{% load qr_code %}

<h1>My QR Code</h1>
<p>This is a QR code for example.com:</p>
{% qr_from_text "https://example.com" size="t" image_format="svg" %}

<p>Or a bigger PNG with custom alt text:</p>
{% qr_from_text "https://my-app.com/secret" size="m" image_format="png" alt="Secret link" %}

view raw JSON →