'dict'对象不可调用

时间:2013-08-11 17:23:08

标签: python django elasticsearch django-haystack

我在搜索引擎中使用django和elasticseach,一切顺利,但最近有这个错误 当我想要更改数据库中的所有内容时,例如当我不想从django admin创建新用户时出现此错误:

Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/auth/user/add/

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.comments',
 'gunicorn',
 'django.contrib.admin',
 'djangoratings',
 'taggit',
 'bootstrap_toolkit',
 'mptt',
 'postman',
 'redisboard',
 'django_extensions',
 'avatar',
 'sorl.thumbnail',
 'dajaxice',
 'dajax',
 'endless_pagination',
 'easy_pjax',
 'debug_toolbar',
 'django_nose',
 'haystack',
 'queued_search',
 'saved_searches',
 'darkoob.book',
 'darkoob.social',
 'darkoob.search',
 'darkoob.group',
 'darkoob.post',
 'darkoob.comments',
 'darkoob.migration',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.facebook',
 'allauth.socialaccount.providers.google',
 'allauth.socialaccount.providers.openid',
 'allauth.socialaccount.providers.twitter')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
  372.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  202.             return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  69.             return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
  223.                 return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/admin.py" in add_view
  121.                                                extra_context)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
  223.                 return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in add_view
  1007.                 self.save_model(request, new_object, form, False)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in save_model
  740.         obj.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
  546.                        force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
  664.                                    update_fields=update_fields, raw=raw, using=using)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py" in send
  170.             response = receiver(signal=self, sender=sender, **named)
File "/home/vahid/Workspace/darkoob/darkoob/social/models.py" in create_user_profile
  109.         UserProfile.objects.create(user=instance)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in create
  149.         return self.get_query_set().create(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in create
  402.         obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
  546.                        force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
  664.                                    update_fields=update_fields, raw=raw, using=using)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py" in send
  170.             response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/haystack/signals.py" in handle_save
  47.                 index.update_object(instance, using=using)
File "/usr/local/lib/python2.7/dist-packages/haystack/indexes.py" in update_object
  266.                 backend.update(self, [instance])
File "/usr/local/lib/python2.7/dist-packages/haystack/backends/elasticsearch_backend.py" in update
  177.         self.conn.bulk_index(self.index_name, 'modelresult', prepped_docs, id_field=ID)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py" in decorate
  96.             return func(*args, query_params=query_params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py" in bulk_index
  389.                                  query_params=query_params)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py" in send_request
  253.         prepped_response = self._decode_response(resp)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py" in _decode_response
  280.             json_response = response.json()

Exception Type: TypeError at /admin/auth/user/add/
Exception Value: 'dict' object is not callable

为什么会出现这个错误以及如何修复它?

1 个答案:

答案 0 :(得分:10)

您正在使用requests库的早期版本。 .json属性的API已更改;因为它至少有1.0个库,所以它现在是一个函数。

pyelastic需要requests 1.0或更新版本;升级图书馆。