我设置了以下http://django-grappelli.readthedocs.org/en/2.6.3/index.html
settings.py
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
)
url.py
urlpatterns = patterns('',
(r'^grappelli/', include('grappelli.urls')), # grappelli URLS
(r'^admin/', include(admin.site.urls)), # admin site
)
$ python manage.py collectstatic
因此我的dcharang1.7.1和grappelli2.6.3的pycharm3.4.1告诉我:
追踪(最近的呼叫最后):
文件" D:\ PyCharm 3.4.1 \ helpers \ pycharm \ django_manage.py",第23行,中
run_module(manage_file,None,' main ',True)
文件" D:\ Python27 \ lib \ runpy.py",第176行,在run_module中 fname,loader,pkg_name)
文件" D:\ Python27 \ lib \ runpy.py",第82行,在_run_module_code中 mod_name,mod_fname,mod_loader,pkg_name)
文件" D:\ Python27 \ lib \ runpy.py",第72行,在_run_code中 run_globals中的exec代码
文件" D:\ Documents \ programe \ python \ django \ mysite \ manage.py",第10行,中
execute_from_command_line(sys.argv中)
文件" D:\ Python27 \ lib \ site-packages \ django-1.7.1-py2.7.egg \ django \ core \ management__init __。py",第385行,在execute_from_command_line
utility.execute()
文件" D:\ Python27 \ lib \ site-packages \ django-1.7.1-py2.7.egg \ django \ core \ management__init __。py",354行,执行中
django.setup()
文件" D:\ Python27 \ lib \ site-packages \ django-1.7.1-py2.7.egg \ django__init __。py",第21行,在设置中 apps.populate(settings.INSTALLED_APPS)
文件" D:\ Python27 \ lib \ site-packages \ django-1.7.1-py2.7.egg \ django \ apps \ registry.py",第85行,在填充中 app_config = AppConfig.create(条目)
文件" D:\ Python27 \ lib \ site-packages \ django-1.7.1-py2.7.egg \ django \ apps \ config.py",第116行,在创建中 mod = import_module(mod_path)
文件" D:\ Python27 \ lib \ importlib__init __。py",第37行,在import_module中 导入(名称)
ImportError:没有名为grappellidjango.contrib的模块
答案 0 :(得分:7)
请在settings.py文件中设置以下设置: -
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
我希望以上解决方案能解决您的问题。