LookupError:没有安装带有标签'django_messages'的应用

时间:2017-04-10 14:01:04

标签: python django django-admin django-messages

我正在尝试使用https://github.com/arneb/django-messages并按照以下说明进行操作

pip install django-messages

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'rest_framework',
    'rest_framework.authtoken',
    'oauth2_provider',
    'api',
    'localflavor',
    'django_localflavor_us',
    'django_countries',
    'haystack',
    'django_messages',

]


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('api.urls')),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^messages/', include('django_messages.urls')),
]

当我登录django shell并尝试以下

In [1]: from django_messages.models import Message

In [2]: Message.objects.all()
Out[2]: <QuerySet []>

它工作正常,我可以导入消息模型,但当我尝试在管理员注册它时,它说的是以下错误

from django.contrib import admin
from django_messages.models import Message
admin.site.register(Message)

错误:

Internal Server Error: /admin/
Traceback (most recent call last):
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = get_response(request)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 229, in wrapper
    return self.admin_view(view, cacheable)(*args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 211, in inner
    return view(request, *args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 468, in index
    app_list = self.get_app_list(request)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 451, in get_app_list
    app_dict = self._build_app_dict(request)
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 431, in _build_app_dict
    'name': apps.get_app_config(app_label).verbose_name,
  File "/Users/shivakrishna/.virtualenvs/project/lib/python2.7/site-packages/django/apps/registry.py", line 155, in get_app_config
    raise LookupError(message)
LookupError: No installed app with label 'django_messages'.

问题是什么以及如何解决?

0 个答案:

没有答案