Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'dict' object is not callable

I use django and elasticseach inside for search engine,Everything worked out,but recently have this error when i want change everything in database, for example when i wan't to create an new user from django admin have this error:

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

why this error ocurred and how i can fixed it?

like image 756
Vahid Kharazi Avatar asked Aug 11 '13 17:08

Vahid Kharazi


People also ask

Why is my dictionary object is not callable?

TypeError: ‘dict’ object is not callable Dictionaries are iterable objects. This means that you can access items individually from inside a dictionary. To access an item in a dictionary, you need to use indexing syntax.

How to fix TypeError ‘Dict’ object is not callable in Python?

The “TypeError: ‘dict’ object is not callable” error is raised when you try to use curly brackets to access items from inside a dictionary. To solve this error, make sure you use the proper square bracket syntax when you try to access a dictionary item. Now you have all the knowledge you need to fix this error in your Python code!

What does it mean when a Python object is not callable?

The TypeError object is not callable is raised by the Python interpreter when an object that is not callable gets called using parentheses. This can occur, for example, if by mistake you try to access elements of a list by using parentheses instead of square brackets.

How to check if an object is callable or not?

As the word callable says, a callable object is an object that can be called. To verify if an object is callable you can use the callable () built-in function and pass an object to it. If this function returns True the object is callable, if it returns False the object is not callable.


1 Answers

You are using an early release of the requests library. The API for the .json attribute changed; since at least 1.0 of the library it is now a function.

The pyelastic requires requests 1.0 or newer; upgrade the library.

like image 131
Martijn Pieters Avatar answered Oct 11 '22 08:10

Martijn Pieters