Skip to content

Comments

Fix autoreload regression for empty template DIRS (swev-id: django__django-15572)#508

Open
casey-brooks wants to merge 1 commit intodjango__django-15572from
fix/autoreload-ignore-empty-dirs-swev-15572
Open

Fix autoreload regression for empty template DIRS (swev-id: django__django-15572)#508
casey-brooks wants to merge 1 commit intodjango__django-15572from
fix/autoreload-ignore-empty-dirs-swev-15572

Conversation

@casey-brooks
Copy link

Summary

  • filter empty string entries before normalizing template directories
  • ensure template loaders ignore empty strings and add regression coverage

Testing

  • PYTHONPATH=$PWD:$HOME/.nix-profile/lib/python3.11/site-packages DJANGO_SETTINGS_MODULE=tests.test_sqlite python3 tests/runtests.py template_tests.test_autoreloader_empty_dirs --parallel=1
  • flake8 django/template/autoreload.py tests/template_tests/test_autoreloader_empty_dirs.py

Regression details

Reproduction steps

  1. Configure TEMPLATES[0]['DIRS'] = [''] in a Django project (or via settings override).
  2. Start the development server with python manage.py runserver.
  3. Edit any non-.py file under the project root (e.g., requirements.txt).

Observed behavior

  • get_template_directories() normalizes the empty string to Path.cwd(), so template_changed() returns True for unrelated filesystem changes, and the autoreloader never schedules a full restart.

DEBUG signal output (before fix)

DEBUG django.utils.autoreload: /abs/path/requirements.txt notified as changed. Signal results: [(<function template_changed at django/template/autoreload.py:73>, True)]

Upstream context

@casey-brooks casey-brooks requested a review from a team December 24, 2025 16:54
@casey-brooks
Copy link
Author

Local Verification

  • PYTHONPATH=$PWD:$HOME/.nix-profile/lib/python3.11/site-packages DJANGO_SETTINGS_MODULE=tests.test_sqlite python3 tests/runtests.py template_tests.test_autoreloader_empty_dirs --parallel=1 # 1 passed
  • flake8 django/template/autoreload.py tests/template_tests/test_autoreloader_empty_dirs.py # no issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good — empty template dirs are filtered safely and the regression test covers the scenario.

@rowan-stein rowan-stein changed the base branch from django__django-15572 to main January 11, 2026 20:58
@rowan-stein rowan-stein changed the base branch from main to django__django-15572 January 12, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants