Python ImportError:没有名为system_admin的模块
当我运行服务器时,请使用:Python ImportError:没有名为system_admin的模块,python,django,Python,Django,当我运行服务器时,请使用: $ python manage.py runserver 但是得到下面的错误: Unhandled exception in thread started by <function wrapper at 0x1015d0320> Traceback (most recent call last): File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/utils/
$ python manage.py runserver
但是得到下面的错误:
Unhandled exception in thread started by <function wrapper at 0x1015d0320>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/management/commands/runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/utils/autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/apps/config.py", line 127, in create
import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named system_admin
如果您尚未创建应用程序,并且已将其包含在
设置.py中,则它将始终崩溃,直到您实际为其提供了有效的应用程序。因此,要修复错误,请转到settings.py
查找INSTALLED\u APPS
,并注释掉system\u admin
和user\u admin
行。然后,当您实际创建它们时,您可以取消对它们的注释。问题的原因是您安装的应用程序中的下一行
'django.contrib.system_admin',
Django的contrib模块中没有名为system\u admin
的模块。这可以通过使用
In [1]: import django.contrib
In [2]: dir(django.contrib)
Out[2]:
['__builtins__',
'__cached__',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__path__',
'__spec__',
'admin',
'auth',
'contenttypes',
'messages',
'postgres',
'sessions',
'sites',
'staticfiles']
我想你是想在你安装的应用程序中使用django.contrib.admin
,在问题中包括settings.py。@arpitolanki我已经这样做了。在设置中,我不会将取消注释
和用户管理
添加到已安装的应用程序
。然后从项目目录中的静态
和模板
中删除文件夹。模板不是这里的问题。是的,是的,我刚才对其进行了注释,然后重新运行服务器。好的,我删除了它,因为我不需要这个函数。
In [1]: import django.contrib
In [2]: dir(django.contrib)
Out[2]:
['__builtins__',
'__cached__',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__path__',
'__spec__',
'admin',
'auth',
'contenttypes',
'messages',
'postgres',
'sessions',
'sites',
'staticfiles']