我不知道它是如何可能的,但我的模块无法找到。我想将haystack集成到django应用程序中。当我把它推到openshift时,我在setup.py中指定了'django_haystack',它没有用。所以我将python dist中的haystack包复制到我的django项目中。
.
├── controller
├── database
├── django_crontab
├── faq
├── haystack
├── lib
├── registration
├── stocks
└── whoosh
我在settings.py中的installed_apps中添加了'haystack'。为了确保我的localhost中的这个包有效,我通过pip在python dist-packages中卸载了django_haystack。在localhost上它可以工作。我正在尝试将haystack.forms导入stocks.forms。 我将新提交推送到openshift。我尝试加载我的网站时收到错误代码500。错误是:
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] ImportError: No module named forms
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] mod_wsgi (pid=262837): Exception occurred processing WSGI script '/var/lib/openshift/526ed6ba4382eca6ff000024/app-root/runtime/repo/wsgi/application'.
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] Traceback (most recent call last):
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba4382eca6ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/wsgi.py", line 255, in __call__
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] response = self.get_response(request)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/base.py", line 178, in get_response
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/handlers/base.py", line 220, in handle_uncaught_exception
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] if resolver.urlconf_module is None:
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/core/urlresolvers.py", line 342, in urlconf_module
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] self._urlconf_module = import_module(self.urlconf_name)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/Django-1.5.5-py2.7.egg/django/utils/importlib.py", line 35, in import_module
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] __import__(name)
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/app-root/runtime/repo/wsgi/digrin/controller/urls.py", line 3, in <module>
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] from stocks.forms import AdvancedSearchForm, AutocompleteModelSearchForm
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] File "/var/lib/openshift/526ed6ba43826ff000024/app-root/runtime/repo/wsgi/digrin/stocks/forms.py", line 31, in <module>
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] from haystack.forms import ModelSearchForm
[Mon Mar 24 16:10:35 2014] [error] [client 127.3.111.129] ImportError: No module named forms
ImportError: No module named forms
所以它基本上首先提到干草堆应用程序。我使用ssh登录了我的openshift帐户并运行了./manage.py shell
,我尝试了from haystack.forms import ModelSearchForm
。它装载没有问题。
我在这里没有想法,我还尝试了./manage.py syncdb
和./manage.py migrate
,以防干草堆错过了一些数据库表。还尝试重新启动应用程序。没有帮助。我错过了什么?
好的,我从我的应用中删除了文件夹haystack,并按照说明将django_haystack添加到setup.py.
我查看了haystack文件夹中本地服务器中的文件:
lucas03@Mirko:~$ ls /usr/local/lib/python2.7/dist-packages/haystack
admin.py constants.pyc fields.pyc indexes.pyc inputs.pyc models.py query.py signals.py urls.py views.pyc
admin.pyc exceptions.py forms.py __init__.py management models.pyc query.pyc signals.pyc urls.pyc
backends exceptions.pyc forms.pyc __init__.pyc manager.py panels.py routers.py templates utils
constants.py fields.py indexes.py inputs.py manager.pyc panels.pyc routers.pyc templatetags views.py
这就是manage.py指向干草堆的地方。
>>> import haystack
>>> haystack
<module 'haystack' from '/var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/haystack-0.16-py2.7.egg/haystack/__init__.pyc'>
>>>
这是我的openshift干草堆内容:
ls /var/lib/openshift/526ed6ba43826ff000024/python/virtenv/lib/python2.7/site-packages/haystack-0.16-py2.7.egg/haystack/
abouchet.py basicmodel.pyc dump_loader.py listmodel.py memory_dumper.pyc model.py win-dump-heap.py
abouchet.pyc config.py dump_loader.pyc listmodel.pyc memory_mapper.py model.pyc win-dump-heap.pyc
argparse_utils.py config.pyc gui __main__.py memory_mapper.pyc reverse
argparse_utils.pyc dbg.py __init__.py __main__.pyc memory_mapping.py utils.py
basicmodel.py dbg.pyc __init__.pyc memory_dumper.py memory_mapping.pyc utils.pyc
这些是我的网站套餐: 站点包] GT; LS
argparse-1.2.1-py2.7.egg easy-install.pth pip setuptools
Digrin.egg-link easy_install.py pip-1.4-py2.7.egg-info setuptools-0.9.8-py2.7.egg-info
Django-1.5.5-py2.7.egg easy_install.pyc pkg_resources.py six-1.4.1-py2.7.egg
django_extensions-1.2.5-py2.7.egg haystack-0.16-py2.7.egg pkg_resources.pyc South-0.8.2-py2.7.egg
django_haystack-2.1.0-py2.7.egg _markerlib python_ptrace-0.7-py2.7.egg
答案 0 :(得分:0)
我将django_haystack版本添加到setup.py,删除了site-packages中的haystack-0.16-py2.7.egg文件夹并且它可以正常工作。不知道我在那里得到了旧版本。