问题描述
当我想在服务器上部署django项目时,我被困在这个过程当中。当我在服务器上运行 python manage.py runserver
时,终端向我显示:
I was stuck with the process when I wanted to deploy django project on server today. When I run python manage.py runserver
on server, the terminal shows me this:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 177, in fetch_command
commands = get_commands()
File "/usr/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 72, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
服务器上的django版本为1.8.5,本地为1.8.1。我怀疑版本可能会导致这个问题。但我也怀疑 wsgi.py
未正确写入,这里是 wsgi.py
:
The django version on the server is 1.8.5, and the local is 1.8.1. I doubt the version may cause this problem. But I also doubted the wsgi.py
wasn't written properly, here's the wsgi.py
:
import os
import sys
path = '/Users/Peterhon/Desktop/dict/'
if path not in sys.path:
sys.path.append(path)
os.chdir(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dict.settings")
import django
django.setup()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
这里是 manage.py
文件:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dict.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.arg)
当我运行python管理。 py检查服务器上,输出如下:
When I run python manage.py check on server, the output is below:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dict.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
任何人都可以给我一些提示?感谢太多
Could anyone give me some tips? Thanks too much
推荐答案
这可能是Django设置的一个问题。例如,我刚刚在不存在的目录中的 LOGGING
中指定了一个文件名。一旦我将其更改为现有的目录,问题已解决。
This could well be an issue with your Django settings. For example, I just had specified in LOGGING
a filename in a non-existent directory. As soon as I changed it to an existing directory, the issue was resolved.
这篇关于django:django.core.exceptions.AppRegistryNotReady:Apps尚未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!