1

我正在尝试使用 python 2.7 在 pythonAnywhere 上部署我的 django 1.6.4 项目

我已经根据网站上的指南配置了虚拟环境和 wsgi 文件。但是当我检查网站时,我得到了 404。错误大声笑告诉我:

ImportError:无法导入设置'tango_with_django_project.settings'(它在sys.path上吗?设置文件中是否存在导入错误?):没有名为tango_with_django_project.settings的模块

这是我的wsgi:

# +++++++++++ DJANGO +++++++++++

# TURN ON THE VIRTUAL ENVIRONMENT FOR YOUR APPLICATION
activate_this = '/home/pjestrada/.virtualenvs/rango/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

# To use your own django app use code like this:
import os
import sys
#
## assuming your django settings file is at '/home/pjestrada/mysite/settings.py'
path = '/home/pjestrada/rango/tango_with_django_project'

if path not in sys.path:
    sys.path.append(path)

os.chdir(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'tango_with_django_project.settings'
#
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我的树:

├── Dropbox
│   ├── README.txt
│   └── __init__.py
├── README.txt
└── rango
    ├── LICENSE
    ├── README.md
    └── tango_with_django_project
        ├── manage.py
        ├── media
        │   ├── profile_images
        │   │   └── 10411981_634016890008979_1609187547738555774_n.jpg
        │   └── rango2.jpg
        ├── populate_rango.py
        ├── rango
        │   ├── __init__.py
        │   ├── __init__.pyc
        │   ├── admin.py
        │   ├── admin.pyc
        │   ├── bing_search.py
        │   ├── bing_search.pyc
        │   ├── forms.py
        │   ├── forms.pyc
        │   ├── models.py
        │   ├── models.pyc
        │   ├── tests.py
        │   ├── urls.py
        │   ├── urls.pyc
        │   ├── views.py
        │   └── views.pyc
        ├── static
        │   ├── about.jpg
        │   ├── css
        │   │   ├── bootstrap-fluid-adj.css
        │   │   ├── bootstrap-responsive.css
        │   │   ├── bootstrap-responsive.min.css
        │   │   ├── bootstrap.css
        │   │   └── bootstrap.min.css
        │   ├── img
        │   │   ├── glyphicons-halflings-white.png
        │   │   └── glyphicons-halflings.png
        │   ├── js
        │   │   ├── bootstrap.js
        │   │   ├── bootstrap.min.js
        │   │   ├── jquery-2.1.1.js
        │   │   └── rango-ajax.js
        │   └── rango.jpg
        ├── tango_with_django_project
        │   ├── __init__.py
        │   ├── __init__.pyc
        │   ├── settings.py
        │   ├── settings.pyc
        │   ├── urls.py
        │   ├── urls.pyc
        │   └── wsgi.py
        └── templates
            └── rango
                ├── about.html
                ├── add_category.html
                ├── add_page.html
                ├── base.html
                ├── category.html
                ├── category_list.html
                ├── index.html
                ├── login.html
                ├── page_list.html
                ├── profile.html
                ├── register.html
                ├── restricted.html
                └── search.html
4

1 回答 1

0

尝试更改路径的值。

path = '/home/pjestrada/rango'

该路径是您的项目目录。它对我有用。

于 2015-06-08T17:52:51.630 回答