Reputation: 9443
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?
Upvotes: 3
Views: 8036
Reputation: 1
I had to use absolute path to python in order to run "manage.py".
cmd /k "cd /d C:\path\to\project\.venv\Scripts & activate & python C:\path\to\project\manage.py runserver"
where & activate
runs C:\path\to\project\.venv\Scripts\activate.bat
and & python
runs python at C:\path\to\project\.venv\Scripts\python
you get the same result with:
call "C:\path\to\project\.venv\Scripts\activate.bat"
C:\path\to\project\.venv\Scripts\python "C:\path\to\project\manage.py" runserver
I guess my problem is that i have many pythons installed
Upvotes: 0
Reputation: 9443
Found my solution by encoding this:
@echo off
cmd /k "cd /d C:\path\to\your\env\scripts & activate & cd /d C:\path\to\your\env\[projectname] & python manage.py runserver"
Upvotes: 10
Reputation: 1
If your virtualenv is created via virtualenvwrapper:
workon yourenvname & python manage.py runserver
Upvotes: 0
Reputation: 131
Call the activate.bat
script in your batch file, before you run manage.py
,
CALL \path\to\env\Scripts\activate.bat
python manage.py runserver
Upvotes: 5