Skip to main content

Django QR Code

Latest PyPI version Downloads Documentation Status Build and Test Maintainability

This is an application that provides tools for displaying QR codes on your Django site.

This application depends on the Segno QR Code generator library.

This app makes no usage of the Django models and therefore do not use any database.

Only Python >= 3.10 is supported.

Features

  • Generate QR codes as embedded SVG or PNG images in HTML templates.
  • Customize QR codes with various parameters (size, error correction, border, etc.).
  • Generate URLs for QR code images.
  • Support for specific application QR codes (e.g., contact info, Wi-Fi config).
  • Cache QR code images for performance.
  • Secure QR code image serving with URL protection and user authentication.

Installation

Binary Package from PyPi

In order to use this app in a Django project, the simplest way is to install it from PyPi:

pip install django-qr-code

From the Source Code

In order to modify or test this app you may want to install it from the source code.

Clone the GitHub repository and install dependencies:

git clone https://github.com/dprog-philippe-docourt/django-qr-code
pip install -r requirements.txt -r requirements-dev.txt
python manage.py collectstatic --no-input

Usage

Start by adding qr_code to your INSTALLED_APPS setting like this:

INSTALLED_APPS = (
    # ...,
    'qr_code',
)

You need to load the tags provided by this app in your template with:

{% load qr_code %}

The source code on GitHub contains a simple demo app. Please check out the templates folder for an example of template, and the setting and urls files for an example of configuration and integration.

Example: Inline QR Code

Generate a simple QR code:

{% qr_from_text "Hello World!" size="T" %}

Example: URL QR Code

Generate a URL for a QR code image:

<img src="{% qr_url_from_text "Hello World!" %}" alt="Hello World!">

Advanced Usage of Tags

Refer to the official documentation for tags for more detailed information and advanced usage examples.

Demo Application

If you want to try this app, you may want to use the demo application shipped alongside the source code.

Get the source code from GitHub, follow the installation instructions above, and run the runserver command of Django:

python manage.py runserver

The demo application should be running at http://127.0.0.1:8000/qr-code-demo/.

If you have Docker Compose installed, you can simply run the following from a terminal (this will save you the burden of setting up a proper python environment):

cd scripts
./run-demo-app.sh

The demo application should be running at http://127.0.0.1:8910/qr-code-demo/.

Generating Image Object Representing a QR Code

If you do not want to use Django tags for rendering QR code in a template, you can simply use the API in your code. For instance, qr_code.qrcode.maker.make_qr_code_image will return bytes representing an image according to the image_format passed in the qr_code_options parameter.

Refer to the official API documentation for more detailed information.

Testing

Get the source code from GitHub, follow the installation instructions above, and run the test command of Django:

python manage.py test

This will run the test suite with the locally installed version of Python and Django.

If you have Docker Compose installed, you can simply run the following from a terminal (this will save you the burden of setting up a proper python environment):

cd scripts
./run-tests.sh

This will run the test suite with all supported versions of Python and Django. The test results are stored within tests_result folder.

Projects Using this App

This app is used in the following projects:

  • MyGym Web: a web platform for managing sports clubs. The QR codes are used for importing members' contact information in a phone book.
  • Gymna-Score: a web platform for entering scores during gymnastics competitions organized by the Association Cantonale Jurassienne de Gymnastique (ACJG). The QR codes are used to provide an easy way for the public to follow an ongoing competition. They are also used to authenticate judges that need to enter scores.
  • AC-Ju: a website that generates digital vouchers that can be redeemed at affiliate merchants.

Release files for django-qr-code 4.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-qr-code 4.2.0
File Size Uploaded
django_qr_code-4.2.0.tar.gz 26.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-qr-code 4.2.0
File Interpreter ABI Platform
django_qr_code-4.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.6 kB

Release files / django_qr_code-4.2.0.tar.gz

Download URL django_qr_code-4.2.0.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
902d463fa2de95e4fcbe7d5c99b1d0f0cd5e2617a1d599a51395b59f61d36c21
BLAKE2b-256 checksum
How to use checksums
0947631537614f8d82e74340b172a0f810e9ff455b4fec7499a7ec55d25ebee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / django_qr_code-4.2.0-py3-none-any.whl

Download URL django_qr_code-4.2.0-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2acc6bcc400c609f4e3fdf4d5198231bd8bfee9f66d674a5ed24f6fa50aa0fe
BLAKE2b-256 checksum
How to use checksums
17ba0cc761c650388679b25c48e8e21a9a84eb4c53aa5662a5c25df3bbb91b91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

4.2.0 This release

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page