PTVS Django projects that are created via the "From Existing Python Code" option are not able to be published to Azure websites due to what appears to be a bug in the deployment scripts.
Try the following in VS2013:
- New Project-> From Existing Python Code -> <Select directory with a sample hello world DJango app>
- Under Select Other Features, use the checkbox for "DJango"
- Under Python Environments, create a new virtual environment called "env"
- Use Install Python Package... -> Use pip to install django into env, make sure that env is the active environment
- Run the app to make sure the hello world website runs locally on your machine
- Right-click on the project node and select Publish... Import the publishing file from Azure websites, hit Publish.
The publishing will fail with the following error message:
The command ""\env\ \Scripts\python.exe" -c "from djangoImportTester import settings; print(settings.STATIC_URL)" > "C:\Users\JoeBlow\AppData\Local\Temp\tmp9491.tmp"" exited with code 3
The system cannot find the path specified.
The error seems to be that the path to the python executable in the virtual environment is mangled, it should be: "env\Scripts\python.exe" instead of "\env\ \Scripts\python.exe"
For some reason, in Python projects created from scratch, the path to the python executable in the virtual environment is an absolute path at this point, and all is well. However, in PTVS DJango projects created via the "From Existing Python Code"
option, it seems to use a mangled relative path where the name of the folder containing the virtual environment has an extra pair of backslashes surrounding it.
Thus far, I have found no work-around. This bug presents massive problems for importing other people's Django projects. From all my testing, it seems that PTVS is currently not a valid option for anyone hoping to deploy existing DJango websites to Azure.