Install & Compatibility
Where this runs
tested against v4.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 76.8MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 5.3s · import 0.000s · 76MB
76MB installed
● package 76MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
load qr_code (template tag)
✓ {% load qr_code %}
Used in Django templates to enable QR code generation tags.
QRCodeOptions
✓ from qr_code.qrcode.utils import QRCodeOptions
For configuring QR code generation parameters programmatically.
make_qr_code_with_options
✓ from qr_code.qrcode.utils import make_qr_code_with_options
Function to generate QR codes programmatically without caching.
get_or_make_cached_embedded_qr_code
✓ from qr_code.qrcode.cache import get_or_make_cached_embedded_qr_code
New in 4.2.0 for caching generated embedded QR code HTML, requires Django caching backend.
include qr_code.urls
✓ path('qr_code/', include('qr_code.urls', namespace='qr_code'))
Adds QR code generation URLs to your project's routing for template tags and API.
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" %}
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'Pillow'
Attempting to generate PNG QR codes without the Pillow library installed, which is required for image processing.
fixInstall Pillow: `pip install Pillow` or install `django-qr-code` with the `pil` extra: `pip install "django-qr-code[pil]"`.
django.urls.exceptions.NoReverseMatch: Reverse for 'qr_code_from_text' not found. 'qr_code' is not a registered namespace.
The `qr_code.urls` module is not correctly included in the project's `urls.py` or the specified namespace is incorrect.
fixAdd `path('qr_code/', include('qr_code.urls', namespace='qr_code'))` to your project's `urlpatterns`. PydanticUserError: Pydantic 2.x requires a Pydantic 2.x compatible Pydantic-settings.
Your Pydantic version is incompatible with `django-qr-code` 4.1.0+. It requires Pydantic >= 2.7 for API view validation.
fixUpgrade Pydantic to a compatible version: `pip install "pydantic>=2.7,<3.0"`.
Upgrade
Version history
4.2.0latest on PyPI · released May 8, 2025
Audit
Dependencies
DjangorequiredCore framework requirement, compatible with Django >= 4.2 (including 5.x).
qrcoderequiredUnderlying QR code generation library (specifically >=7.4, <8).
PillowoptionalRequired for generating QR codes as PNG images (specifically >=10.0, <11).
PydanticoptionalRequired for API view validation (specifically >=2.7, <3.0).