Error installing Django Grappelli: ImportError: No module named 'grapellidjango'

Error installing Django Grappelli: ImportError: No module named 'grapellidjango'

我只是遵循了相当简单的 quickstart guide:

urls.py:

urlpatterns = [
    url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS
    ...

settings/base.py:

INSTALLED_APPS = (
    # http://django-grappelli.readthedocs.org/en/latest/quickstart.html
    'grappelli'

    #default apps
    'django.contrib.admin',
    ....

但这导致了主题错误:

ImportError: No module named 'grapellidjango'

确认我已正确安装:

点冻结:

(hackerspace_online)...@sparagus ~/Developer/hackerspace_online/src $ pip freeze
...
Django==1.8.2
...
django-grappelli==2.7.1

检查python路径

ipdb> import grappelli
ipdb> 

我在这个安装中搞砸了什么?

您在 'grappelli' 之后漏掉了逗号。

而不是

INSTALLED_APPS = (
# http://django-grappelli.readthedocs.org/en/latest/quickstart.html
'grappelli'

#default apps
'django.contrib.admin',
....

应该是

INSTALLED_APPS = (
# http://django-grappelli.readthedocs.org/en/latest/quickstart.html
'grappelli',

#default apps
'django.contrib.admin',
....

当你有两个字符串时 python 会自动连接它们。 例如

>>> s = 'hello' 'world'
>>> s
'helloworld'