跳转到主要内容

在Django的自动重新加载器中使用watchfiles。

项目描述

https://img.shields.io/github/actions/workflow/status/adamchainz/django-watchfiles/main.yml.svg?branch=main&style=for-the-badge https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge https://img.shields.io/pypi/v/django-watchfiles.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit

在Django的自动重新加载器中使用watchfiles


通过我的书籍提升您的Django和Git技能(书籍链接)


要求

支持Python 3.8到3.12。

支持Django 3.2到5.1。

安装

  1. 使用

    pip

    安装

    python -m pip install django-watchfiles
  2. 将django-watchfiles添加到您的INSTALLED_APPS

    INSTALLED_APPS = [
        ...,
        "django_watchfiles",
        ...,
    ]

就这样! 😅

Django不提供官方API用于替代自动重新加载器类。因此,django-watchfiles对django.utils.autoreload进行猴子补丁,使其自己的重新加载器成为唯一可用的类。您可以告诉它已安装,因为runserver会列出正在使用的WatchfilesReloader

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

与Django内置的WatchmanReloader不同,无需回退到StatReloader,因为watchfiles实现了自己的内部回退,使用stat

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

django_watchfiles-0.2.0.tar.gz (5.1 kB 查看哈希值)

上传时间 源代码

构建分发

django_watchfiles-0.2.0-py3-none-any.whl (4.6 kB 查看哈希值)

上传时间 Python 3