Repository: cookiecutter/cookiecutter-django
Pull request: Fix `runserver_plus` hot-reload when under Windows + Docker
## Description
Supporting django auto reload in windows docker.

## Rationale
Now it doesn't reload when django code is changed in windows docker env.
The problem is related to wsl2 and Werkzeug's built-in reloading system.
So it can be fixed with stat polling options.

FIX #4970 

Problem statement:
Why doesn't add RunServerPlus options for reload in windows when using docker?
## Description

What are you proposing? How should it be implemented?

Add this code when window = y when generating project, for reloading django code in window.

```
end of base.py
# RunServerPlus
# ------------------------------------------------------------------------------
{% if cookiecutter.windows == 'y' %}
# After how many seconds auto-reload should scan for updates in poller-mode
RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 5

# Werkzeug reloader type [auto, watchdog, or stat]
RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
{% endif %}
```

## Rationale

Why should this feature be implemented?
In window with docker, somehow(might be filesytem problem) reload doens't work with default RELOADER_TYPE.
So we should add above code but when the first time using cookiecutter, all of users don't realize what happens like me.
So it should be set by default when windows option as y in generating project step.

Hints from issue discussion:
This would definitely help, can you submit a PR? 
> This would definitely help, can you submit a PR? 

Yeah. It is honor to me. I will make a pr soon. I hope you review my code. 😀

Commit message: Add options to reload django when file changes in windows docker

Patch to review:
diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py
index f1edb514ba..0f36662ec0 100644
--- a/{{cookiecutter.project_slug}}/config/settings/local.py
+++ b/{{cookiecutter.project_slug}}/config/settings/local.py
@@ -83,6 +83,15 @@
         # The node container isn't started (yet?)
         pass
     {%- endif %}
+{% if cookiecutter.windows == 'y' %}
+# RunServerPlus
+# ------------------------------------------------------------------------------
+# After how many seconds auto-reload should scan for updates in poller-mode
+RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 5
+
+# Werkzeug reloader type [auto, watchdog, or stat]
+RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
+{% endif %}
 {%- endif %}
 
 # django-extensions


Code review comments:
diff_hunk: @@ -83,6 +83,15 @@
         # The node container isn't started (yet?)
         pass
     {%- endif %}
+{% if cookiecutter.windows == 'y' %}
+# RunServerPlus
+# ------------------------------------------------------------------------------
+# After how many seconds auto-reload should scan for updates in poller-mode
+RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 5
path: {{cookiecutter.project_slug}}/config/settings/local.py
text: @user1:
5 seconds seems a bit long, no? The default value of 1 second seems more appropriate:

```suggestion
RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 1
```

Actually, since it's the default interval, do we need to define it? I think we could omit it...

diff_hunk: @@ -83,6 +83,15 @@
         # The node container isn't started (yet?)
         pass
     {%- endif %}
+{% if cookiecutter.windows == 'y' %}
+# RunServerPlus
+# ------------------------------------------------------------------------------
+# After how many seconds auto-reload should scan for updates in poller-mode
+RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 5
+
+# Werkzeug reloader type [auto, watchdog, or stat]
+RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
+{% endif %}
path: {{cookiecutter.project_slug}}/config/settings/local.py
text: @user1:
To avoid leaving an extra empty line:

```suggestion
{%- endif %}
```

diff_hunk: @@ -83,6 +83,15 @@
         # The node container isn't started (yet?)
         pass
     {%- endif %}
+{% if cookiecutter.windows == 'y' %}
path: {{cookiecutter.project_slug}}/config/settings/local.py
text: @user1:
I'm not sure it will change much in the final formatting, but I tend to add a minus sign to [trim empty lines before the Jinja tags](https://jinja.palletsprojects.com/en/2.10.x/templates/#whitespace-control), and add an explicit emtpy line after:

```suggestion
{%- if cookiecutter.windows == 'y' %}

```

I found it easier to see where the empty line will be when the codition is true or false.

@author:
Yeah, it looks better. and also it should be add indent too.