Set django in sae to make the working environment of sae consistent with that of the local python environment, djangopython

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.