python-django 部署

trouble shooting:

1.ImportError: Could not import settings ‘mysite.settings’ when deploying django? just add the following to the wsgi.py file:
[cce_ruby]
import sys
sys.path = [‘/home/mysite/prg/mysite/mysite_django’, ‘/home/mysite/prg/mysite’] + sys.path

[/cce_ruby]

2. you can confirm the problem by:
[cce_ruby]
python
>>>import sys
>>>print sys.path
# you will find there is no directory of your django root. that's the problem
>>> sys.path = ['/home/mysite/prg/mysite/mysite_django', '/home/mysite/prg/mysite'] + sys.path
>>>import mysite_django.settings
# this should be no errors 
[/cce_ruby]
3. a config file of apache should like this:
[cce_ruby]
<VirtualHost mysite.com:80>
    WSGIDaemonProcess mysite.com python-path=/usr/lib/python2.7/site-packages:/var/www/html/mysite/django
    WSGIScriptAlias / /var/www/html/mysite/django/mysite/wsgi.py
    ServerAdmin abc@gmail.com
    DocumentRoot /var/www/html/mysite/django
    ServerName mysite.com
    ErrorLog /var/log/httpd/apply.mysite.com-error.log
    CustomLog /var/log/httpd/apply.mysite.com-access.log combined
    <Directory /var/www/html/mysite/django>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
[/cce_ruby]

reference from : http://stackoverflow.com/questions/8052559/how-to-troubleshoot-importerror-could-not-import-settings-mysite-settings-w

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注