How to Build a QR Code Generator in Django (Step-by-Step Guide)

Published: (February 23, 2026 at 06:16 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Introduction

QR codes are widely used for payments, marketing campaigns, Wi‑Fi sharing, and WhatsApp links. In this tutorial we’ll build a simple QR‑code generator using Django and Python.

Installation

pip install qrcode[pil]

View

Create a view in your Django app:

import qrcode
from django.http import HttpResponse
from io import BytesIO

def generate_qr(request):
    data = request.GET.get("data", "Hello World")

    qr = qrcode.make(data)
    buffer = BytesIO()
    qr.save(buffer, format="PNG")

    return HttpResponse(buffer.getvalue(), content_type="image/png")

You can now access the generator at:

http://localhost:8000/generate_qr/?data=Hello

The QR code will be generated dynamically.

URL Configuration

Add the view to urls.py:

from django.urls import path
from .views import generate_qr

urlpatterns = [
    path("generate_qr/", generate_qr),
]

Extending the Project

You can support additional QR‑code types, such as:

  • Wi‑Fi QR codes
  • WhatsApp QR codes
  • Email QR codes
  • vCard contact QR codes
  • Custom colors
  • Logos inside QR codes

Example: Generating a WhatsApp QR code

phone_number = "1234567890"
data = f"https://wa.me/{phone_number}"

Deployment Considerations

  • Add caching for performance
  • Implement rate limiting
  • Optimize SEO for each QR type
  • Add multilingual support
  • Create a frontend interface

Production Example

A production‑ready example with multilingual support and multiple QR formats is available at:
fastools.online/en

Use Cases

  • SaaS tool
  • Marketing utility
  • Developer tool
  • Multilingual QR platform

Conclusion

Building a QR‑code generator in Django is simple and scalable. Django’s flexibility makes it easy to turn this project into a powerful tool for various applications.

Happy coding!

0 views
Back to Blog

Related posts

Read more »

My Developer Portfolio — Umer Azmi

Hi, I'm Umer Azmi, a Frontend Developer and Python Developer from Mumbai, India. Projects and Contributions 👉 https://github.com/UmerAzmihttps://github.com/Ume...

Introduction to HTML Basics

What is HTML? HTML stands for Hyper Text Markup Language. It is used to create web pages and structure content on the internet. Every website you see is built...