Set django in sae to make the working environment of sae consistent with that of the local python environment, djangopython
In sae, a python environment is installed. If you want sae to import the downloaded django or other modules, you can create a new file directory in svn, such as site-packages, which is the same as the python installation directory, this directory stores all python modules (including django), copies various modules under the installation directory and installed with pip install into this directory, and then adds the python search path, this allows sae to introduce various modules from this directory to ensure the normal operation of the program. the specific settings are as follows:
Step 1: Modify the wsgi. py file after the project directory generated by django, such as ../mysite/wsgi. py
Import OS
Import sys
Root = OS. path. join (OS. path. dirname (OS. path. dirname (_ file _), 'site-packages ') # obtain the newly added site-packages path.
Sys. path. insert (0, root) # Add this path to the system's environment variable so that the default path for the first search in python is this path.
OS. environ. setdefault ("DJANGO_SETTINGS_MODULE", "mysite. settings ")
From django. core. wsgi import get_wsgi_application
Application = get_wsgi_application ()
Step 2: Create an index. wsgi file in the django root directory (that is, the same directory as manage. py,
Import sae
From mysite import wsgi
Application = sae. create_wsgi_app (wsgi. application)
Since then, the python configuration in sae is exactly the same as that in the local python. You only need to copy the required modules to the custom directory, and then synchronize the svn to operate sae like local python.