# django-browser-reload **Repository Path**: mirrors_adamchainz/django-browser-reload ## Basic Information - **Project Name**: django-browser-reload - **Description**: Automatically reload your browser in development. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-16 - **Last Updated**: 2025-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ===================== django-browser-reload ===================== .. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/django-browser-reload/main.yml.svg?branch=main&style=for-the-badge :target: https://github.com/adamchainz/django-browser-reload/actions?workflow=CI .. image:: https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge :target: https://github.com/adamchainz/django-browser-reload/actions?workflow=CI .. image:: https://img.shields.io/pypi/v/django-browser-reload.svg?style=for-the-badge :target: https://pypi.org/project/django-browser-reload/ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge :target: https://github.com/psf/black .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge :target: https://github.com/pre-commit/pre-commit :alt: pre-commit Automatically refresh your browser on changes to Python code, templates, or static files. ---- **Work smarter and faster** with my book `Boost Your Django DX `__ which covers django-browser-reload and many other tools. I wrote django-browser-reload whilst working on the book! ---- Requirements ------------ Python 3.9 to 3.14 supported. Django 4.2 to 6.0 supported. Both WSGI and ASGI are supported. Your browser needs to support: * |EventSource|__ - universally available. .. |EventSource| replace:: ``EventSource`` __ https://developer.mozilla.org/en-US/docs/Web/API/EventSource#browser_compatibility * |SharedWorker|__ - available on Chrome, Edge, Firefox, and Opera for a long time. Available on Safari since version 16 (2022-09-12). .. |SharedWorker| replace:: ``SharedWorker`` __ https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker#browser_compatibility Installation ------------ 1. Install with **pip**: .. code-block:: sh python -m pip install django-browser-reload 2. Ensure you have ``"django.contrib.staticfiles"`` in your ``INSTALLED_APPS``. 3. Add django-browser-reload to your ``INSTALLED_APPS``: .. code-block:: python INSTALLED_APPS = [ ..., "django_browser_reload", ..., ] 4. Include the app URLs in your root URLconf: .. code-block:: python from django.urls import include, path urlpatterns = [ ..., path("__reload__/", include("django_browser_reload.urls")), ] You can use another prefix if required. 5. Add the middleware: .. code-block:: python MIDDLEWARE = [ # ... "django_browser_reload.middleware.BrowserReloadMiddleware", # ... ] The middleware should be listed after any others that encode the response, such as Django’s ``GZipMiddleware``. The middleware automatically inserts the required script tag on HTML responses before ```` when ``DEBUG`` is ``True``. It does so to every HTML response, meaning it will be included on Django’s debug pages, admin pages, etc. If you want more control, you can instead insert the script tag in your templates—see below. All done! 📯 Try installing `django-watchfiles `__ as well, for faster and more efficient reloading. Usage ----- Once set up as above, just run ``runserver`` with the ``DEBUG`` setting set to ``True``, and open your site in a browser. When you modify Python code, templates, or static assets, the page will automatically reload. Welcome to much faster iteration times! If you open multiple tabs, only the most recently used tab will reload. django-browser works by adding a script tag into HTML responses, just before ````. This script connects back to the development server and receives events that tell it when to reload. These events are triggered through server restarts and ``runserver``\’s autoreload system. See below for a more detailed explanation, under “How It Works”. On Django 6.0+ with ``ContentSecurityPolicyMiddleware``, the ``