Running Python Django Project in Windows Operating System with .bat File

When developing projects with Django, the constant and annoying work is to restart the project. In this post, if you are a Windows user, you can easily run your project by creating a .bat file on your desktop. I use Windows 10 as the operating system.

You can open the following lines of code with a code editor such as Visual Studio Code, Pycharm, and save it on your desktop as a .bat extension.

@REM Comment line : Changing the active console code page to UTF-8
chcp 65001
@REM Comment line : switch to project folder
cd C:\Users\etem\Desktopd\django_proje_klasoru
@REM Comment line : Activating the base virtual environment since I use anaconda.
call activate base
@REM Comment line : Starting our project with python3.exe from Anaconda folder.
C:\Users\etem\anaconda3\python3.exe runserver


When you click on the file you created on the desktop, for example django_project.bat, your project will be run automatically.

If you copy the .bat file you created to the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp folder, your project will run automatically every time your computer starts.

Good luck.