Shift N' Tab Shift N' Tab - 2 months ago 16
Python Question

How to run django server with ACTIVATED virtualenv using batch file (.bat)

I found this post to be useful on how to code a batch file to automate django web server start.

But the problem is, there is no virtualenv activated, How can i activate it before the manage.py runserver inside the script?

I would like to run this server with virtualenv activated via batch file.


Answer

Found my solution by encoding this:

@echo off
cmd /k "cd /d C:\Users\[user]\path\to\your\env\scripts & activate & cd /d C:\Users\[user]\path\to\your\env\[projectname] & python manage.py runserver"