Skip to main content

Use watchfiles in Django’s autoreloader.

Project description

dj-watchfiles

Run tests and upload coverage Codecov PyPI version

Use watchfiles in Django's autoreloader.


dj-watchfiles is a fork of django-watchfiles, adds support for managing verbosity level.


Requirements

Python 3.9 to 3.13 supported.

Django 4.2 to 5.1 supported.

Installation

  1. Install with pip:

    python -m pip install dj-watchfiles
    
  2. Install with uv:

    uv add dj-watchfiles
    
  3. Add dj-watchfiles to your INSTALLED_APPS:

    INSTALLED_APPS = [
         ...,
         "dj_watchfiles",
         ...,
     ]
    

That's it!

Verbosity configuration

You can control the verbosity level either through Django settings or CLI.

  1. Django Settings

     WATCHFILES = {
       "verbosity": 2,  # Default is 1
     }
    
  2. CLI

     python manage.py runserver --verbosity 2
    

Verbosity Levels

Verbosity level Log level What you'll see
0 ERROR Only errors
1 WARNING Warnings and errors (Default)
2 INFO Info, warnings, and errors
3 DEBUG All messages including debug info

Other settings you can get from the project settings WATCHFILES, e.g.:

WATCHFILES = {
     "watch_filter": "path.to.custom_filter",
     "raise_interrupt": False,
     "debug": True,  # False by default
   }

Note: Setting debug = True is more like a hard override that ignores the verbosity setting completely and sets the verbosity level to 3 (DEBUG level).


Django doesn't provide an official API for alternative autoreloader classes. Therefore, dj-watchfiles monkey-patches django.utils.autoreload to make its own reloader the only available class. You can tell it is installed as runserver will list WatchfilesReloader as in use:

$ ./manage.py runserver
Watching for file changes with WatchfilesReloader
...

Unlike Django's built-in WatchmanReloader, there is no need for a fallback to StatReloader, since watchfiles implements its own internal fallback to using stat.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj_watchfiles-2.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_watchfiles-2.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file dj_watchfiles-2.0.0.tar.gz.

File metadata

  • Download URL: dj_watchfiles-2.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dj_watchfiles-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1f024cbd97f67a03242dc8c57908685b9364097f63148fc726cb45fc097b92ae
MD5 4742e1fd3b09b7fb900869a967eeee19
BLAKE2b-256 37f16473b18493a64acdcde60bc2c2ca7241688fa629b8da05dee1183ef4e101

See more details on using hashes here.

File details

Details for the file dj_watchfiles-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: dj_watchfiles-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dj_watchfiles-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f737563e63cb5ed5ca119b5270f3047ccf3a6123914f7be50ea4a837423635c4
MD5 acf02e7520bd9f5e0360194718972241
BLAKE2b-256 5124ab765a50e319a29b6b3d87a0971b9a036405fab058074b66fac2950ffb7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page