Use watchfiles in Django’s autoreloader.
Project description
dj-watchfiles
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
-
Install with pip:
python -m pip install dj-watchfiles
-
Install with uv:
uv add dj-watchfiles
-
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.
-
Django Settings
WATCHFILES = { "verbosity": 2, # Default is 1 }
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dj_watchfiles-2.0.1.tar.gz.
File metadata
- Download URL: dj_watchfiles-2.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98a8650c8976e123e41faabe59975de02ef196cd29a2d4307b05d5a32a1aefd2
|
|
| MD5 |
a4fe7be8057c592d826935eadff0733c
|
|
| BLAKE2b-256 |
ac947e5b0bc3d2ee11f309437737a1d95e1400eb7acfc9754a9cfe053f82fb51
|
File details
Details for the file dj_watchfiles-2.0.1-py3-none-any.whl.
File metadata
- Download URL: dj_watchfiles-2.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee42baf3fcd0313a17a94bb4a2f7e07a63dc5957446b91317bfa3f3fc69ce21b
|
|
| MD5 |
06a11d1e0f8f7b1e46d9e556af5fa20d
|
|
| BLAKE2b-256 |
e58dd4bf4ede6fc6b239b5551ca7a5a3ec00f8404e5e15ec88c4241ed15b6907
|