From 90c0eda561e56ae861bd15dc12f0d1670b8d9800 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Mar 2026 12:07:18 +0000 Subject: [PATCH] fix: Add patch for Django issue #30479 - StatReloader doesn't track manage.py Apply this patch to django/utils/autoreload.py to fix the regression where changes to manage.py don't trigger autoreloader restart. The fix adds special case handling for the __main__ module which has __spec__ = None but still needs to be tracked for file changes. Example usage: git apply django-autoreloader-30479.patch --- django-autoreloader-30479.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 django-autoreloader-30479.patch diff --git a/django-autoreloader-30479.patch b/django-autoreloader-30479.patch new file mode 100644 index 000000000..f6c08b4a0 --- /dev/null +++ b/django-autoreloader-30479.patch @@ -0,0 +1,17 @@ +--- a/django/utils/autoreload.py ++++ b/django/utils/autoreload.py +@@ -80,6 +80,11 @@ def iter_modules_and_files(modules, include_packages=False): + """ + Iterate over all modules and yield their filenames. + """ + for module in modules: ++ # Special case for __main__ module (e.g., manage.py) ++ # It has __spec__ = None but we still want to track it ++ if module.__name__ == '__main__': ++ if hasattr(module, '__file__') and module.__file__: ++ yield module.__file__ ++ continue ++ + spec = getattr(module, "__spec__", None) + if spec is None: + continue