Django Browser Reload

1.21.0 · active · verified Tue Apr 14

django-browser-reload is a Django application that automatically refreshes your web browser during development when changes are detected in Python code, templates, or static files. It helps improve the development workflow by eliminating manual browser reloads. The current version is 1.21.0, and it actively supports Python versions 3.9 to 3.14 and Django versions 4.2 to 6.0. It is actively maintained.

Warnings

Install

Imports

Quickstart

To quickly set up `django-browser-reload`, install it via pip, then add `django_browser_reload` to your `INSTALLED_APPS` and `BrowserReloadMiddleware` to your `MIDDLEWARE` in `settings.py`. Crucially, `DEBUG` must be `True`. Finally, include `django_browser_reload.urls` in your project's main `urls.py`, ideally wrapped in a `if settings.DEBUG:` block. Once configured, run `python manage.py runserver`, and your browser will automatically refresh on code, template, or static file changes.

import os
from pathlib import Path
from django.conf import settings # Import settings to check DEBUG
from django.urls import include, path

# --- settings.py (abbreviated) ---
# Make sure DEBUG is True for development
DEBUG = True

# Required for static files
INSTALLED_APPS = [
    # ... existing Django apps
    'django.contrib.staticfiles',
    'django_browser_reload',
]

# Add BrowserReloadMiddleware to your MIDDLEWARE list
# It should come after any middleware that encodes the response (e.g., GZipMiddleware)
MIDDLEWARE = [
    # ... existing middleware
    'django_browser_reload.middleware.BrowserReloadMiddleware',
]

# --- urls.py (abbreviated) ---
# Include django-browser-reload's URLs
urlpatterns = [
    path('admin/', admin.site.urls),
]

# Conditionally add the reload URLs in DEBUG mode
if settings.DEBUG:
    urlpatterns += [
        path("__reload__/", include("django_browser_reload.urls")),
    ]

# To run:
# 1. Ensure you have a Django project set up.
# 2. Add the above settings and URL patterns.
# 3. Run: python manage.py runserver
# 4. Open your browser to http://127.0.0.1:8000/ and modify a Python file, template, or static file.

view raw JSON →