Just create a .bat
file. Example like this:
start cmd /k "cd E:\OE_Monitoring && oenv\Scripts\activate.bat && cd src\oe_project && python manage.py runserver 127.0.0.1:8000"
General syntax
start cmd /k "cd YourPathFolder && YourVirtualEnvironment\Scripts\activate.bat && cd YourPath\FolderContainManagePy && python manage.py runserver your_address:your_port"
Or you can add default address
and default port
in your settings.py
:
from django.core.management.commands.runserver import Command as runserver
ALLOWED_HOSTS = ['*']
runserver.default_port = '8000'
runserver.default_addr = '127.0.0.1'
And file script just need run python manage.py runserver
instead of python manage.py runserver 127.0.0.1:8000
Another case: If location of script at drive D
and you want run project at drive E
, we need change drive first (example E: && cd your_path...
), but I recommend put script into project folder.
start cmd /k "YourDrive: && cd YourFolder && YourVirtualEnvironment\Scripts\activate.bat && cd YourPath\FolderContainManagePy && python manage.py runserver your_address:your_port"