I have a batch script for the purpose of setting up a dev environment for a Django instance. Part of this is setting the DJANGO_SETTINGS_MODULE
environment variable. If no arguments are supplied the script runs this block of code:
for %%* in (.) do set DIR=%%~n*
set DJANGO_SETTINGS_MODULE=%DIR%.dev_settings
When the script is first called it sets DJANGO_SETTINGS_MODULE
to only .dev_settings
. When I run the script a second time in the same terminal it sets it correctly from the directory name.
I have no idea why this is the case.
Below is the full script in case you need full context.
@echo off
IF "%1"=="-r" (
set "DJANGO_SETTINGS_MODULE="
) ELSE IF "%1"=="" (
start cmd /c prp-sql
for %%* in (.) do set DIR=%%~n*
set DJANGO_SETTINGS_MODULE=%DIR%.dev_settings
) ELSE IF "%2"=="" (
start cmd /c prp-sql
set DJANGO_SETTINGS_MODULE=%1.dev_settings
) ELSE (
start cmd /c prp-sql
set DJANGO_SETTINGS_MODULE=%1.%2
)