__init__() got an unexpected keyword argument 'mimetype'

Guddu picture Guddu · Feb 27, 2015 · Viewed 18.8k times · Source

I am using Django 1.7.4 and django_ajax_selects for AutoComplete.

The lookup is failing and i get this error:

__init__() got an unexpected keyword argument 'mimetype'

The complete stack trace is as below. What could i do to resolve this error?

Is it ok that a GET is called instead of a POST. Does django_ajax_select does a GET and not POST?

TypeError at /autocomplete/lookup/ajax_lookup/TableItemLookup
__init__() got an unexpected keyword argument 'mimetype'

Request Method: GET
Request URL: http://127.0.0.1:8999/RESTO/autocomplete/lookup/ajax_lookup/TableItemLookup?term=Sam
Django Version: 1.7.4
Python Executable: C:\Apache Software Foundation\Apache2.2\bin\httpd.exe
Python Version: 2.7.6
Python Path: ['C:\\Python27\\lib\\site-packages\\setuptools-2.0.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\django_debug_toolbar-0.11.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\requests-2.2.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\suds_jurko-0.6-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\elaphe-0.6.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\pillow-2.3.0-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\ghostscript-0.5dev-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\south-0.8.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\crochet-1.0.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\django_ajax_selects-1.3.4-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\scrapy-0.22.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\six-1.7.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\cssselect-0.9.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\pyopenssl-0.14-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\queuelib-1.1.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\w3lib-1.6-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\python_dateutil-1.5-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\memory_profiler-0.32-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\cython-0.21.1-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\line_profiler-1.0-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\pika-0.9.14-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\pyws-1.1.5-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\nose-1.3.4-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\jinja2-2.7.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\httplib2-0.9-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\argparse-1.3.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\soapfish-0.6dev-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\soapbox-0.3.8.dev-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\num2words-0.5.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\unidecode-0.04.17-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\Lib', 'C:\\Python27\\DLLs', 'C:\\Python27\\Lib\\lib-tk', 'C:\\Apache Software Foundation\\Apache2.2', 'C:\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'D:/RESTO/RESTO\\..', 'D:/RESTO/RESTO', 'D:/RESTO/RESTO\\..']
Server time: Fri, 27 Feb 2015 03:04:44 -0300
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'RESTO_App',
 'ajax_select')
Installed Middleware:
('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')

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\django_ajax_selects-1.3.4-py2.7.egg\ajax_select\views.py" in ajax_lookup
  47.     return HttpResponse(results, mimetype='application/javascript')
File "C:\Python27\lib\site-packages\django\http\response.py" in __init__
  318.         super(HttpResponse, self).__init__(*args, **kwargs)

Exception Type: TypeError at /autocomplete/lookup/ajax_lookup/TableItemLookup
Exception Value: __init__() got an unexpected keyword argument 'mimetype'
Request information:
GET:
term = u'Sam'

POST: No POST data

FILES: No FILES data

COOKIES:
csrftoken = '5ZMf6xaGtSuWG9MASQVagsqPQ61puPAh'
sessionid = 'cno7s0h8slwvr7zbvs3laddhiff2hf0p'

META:
wsgi.multiprocess = False
HTTP_REFERER = 'http://127.0.0.1:8999/RESTO/manage_individual_table'
SERVER_PROTOCOL = 'HTTP/1.1'
SERVER_SOFTWARE = 'Apache/2.2.25 (Win32) mod_wsgi/3.3 Python/2.7.6 mod_fcgid/2.3.6'
SCRIPT_NAME = u'/RESTO'
mod_wsgi.handler_script = ''
SERVER_SIGNATURE = ''
REQUEST_METHOD = 'GET'
PATH_INFO = u'/autocomplete/lookup/ajax_lookup/TableItemLookup'
SystemRoot = 'C:\\Windows'
QUERY_STRING = 'term=Sam'
HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36'
HTTP_CONNECTION = 'keep-alive'
HTTP_COOKIE = 'sessionid=cno7s0h8slwvr7zbvs3laddhiff2hf0p; csrftoken=5ZMf6xaGtSuWG9MASQVagsqPQ61puPAh'
SERVER_NAME = '127.0.0.1'
REMOTE_ADDR = '127.0.0.1'
mod_wsgi.request_handler = 'wsgi-script'
wsgi.url_scheme = 'http'
PATH_TRANSLATED = 'C:\\Apache Software Foundation\\Apache2.2\\htdocs\\autocomplete\\lookup\\ajax_lookup\\TableItemLookup'
SERVER_PORT = '8999'
mod_wsgi.version = 
mod_wsgi.input_chunked = '0'
SERVER_ADDR = '127.0.0.1'
DOCUMENT_ROOT = 'C:/Apache Software Foundation/Apache2.2/htdocs'
mod_wsgi.process_group = ''
COMSPEC = 'C:\\Windows\\system32\\cmd.exe'
HTTP_X_REQUESTED_WITH = 'XMLHttpRequest'
SCRIPT_FILENAME = 'D:/RESTO/RESTO/wsgi.py'
wsgi.input = <mod_wsgi.Input object at 0x04C12F98>
HTTP_HOST = '127.0.0.1:8999'
mod_wsgi.callable_object = 'application'
wsgi.multithread = True
PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
REQUEST_URI = '/RESTO/autocomplete/lookup/ajax_lookup/TableItemLookup?term=Sam'
HTTP_ACCEPT = 'application/json, text/javascript, */*; q=0.01'
WINDIR = 'C:\\Windows'
wsgi.version = 
GATEWAY_INTERFACE = 'CGI/1.1'
wsgi.run_once = False
wsgi.errors = <mod_wsgi.Log object at 0x04BEA1D8>
REMOTE_PORT = '55837'
HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.8,es-419;q=0.6,es;q=0.4'
mod_wsgi.application_group = '192.168.1.101:8999|/resto'
mod_wsgi.script_reloading = '1'
wsgi.file_wrapper = ''
CSRF_COOKIE = u'5ZMf6xaGtSuWG9MASQVagsqPQ61puPAh'
HTTP_ACCEPT_ENCODING = 'gzip, deflate, sdch'

Settings:
Using settings module RESTO.settings
USE_L10N = True
USE_THOUSAND_SEPARATOR = False
CSRF_COOKIE_SECURE = False
LANGUAGE_CODE = 'en-us'
ROOT_URLCONF = 'RESTO.urls'
MANAGERS = 
BASE_DIR = 'D:/RESTO/RESTO\\..'
TEST_NON_SERIALIZED_APPS = []
DEFAULT_CHARSET = 'utf-8'
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
STATIC_ROOT = 'D:\\RESTO\\staticfiles'
ALLOWED_HOSTS = []
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
EMAIL_SUBJECT_PREFIX = '[Django] '
SEND_BROKEN_LINK_EMAILS = False
STATICFILES_FINDERS = 
SESSION_CACHE_ALIAS = 'default'
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_NAME = 'sessionid'
ADMIN_FOR = 
TIME_INPUT_FORMATS = 
DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'RESTO', 'CONN_MAX_AGE': 0, 'TIME_ZONE': 'UTC', 'PORT': '5432', 'HOST': 'localhost', 'USER': 'postgres', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'********************', 'OPTIONS': {}}}
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = 
DEFAULT_CONTENT_TYPE = 'text/html'
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
AJAX_SELECT_BOOTSTRAP = True
APPEND_SLASH = True
LOCALE_PATHS = 
DATABASE_ROUTERS = []
DEFAULT_TABLESPACE = ''
YEAR_MONTH_FORMAT = 'F Y'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
SERVER_EMAIL = 'root@localhost'
SESSION_COOKIE_PATH = '/'
SILENCED_SYSTEM_CHECKS = []
MIDDLEWARE_CLASSES = 
USE_I18N = True
THOUSAND_SEPARATOR = ','
SECRET_KEY = u'********************'
LANGUAGE_COOKIE_NAME = 'django_language'
DEFAULT_INDEX_TABLESPACE = ''
TRANSACTIONS_MANAGED = False
LOGGING_CONFIG = 'logging.config.dictConfig'
TEMPLATE_LOADERS = 
FIRST_DAY_OF_WEEK = 0
WSGI_APPLICATION = 'RESTO.wsgi.application'
TEMPLATE_DEBUG = True
X_FRAME_OPTIONS = 'SAMEORIGIN'
CSRF_COOKIE_NAME = 'csrftoken'
FORCE_SCRIPT_NAME = None
USE_X_FORWARDED_HOST = False
SIGNING_BACKEND = 'django.core.signing.TimestampSigner'
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_DOMAIN = None
FILE_CHARSET = 'utf-8'
DEBUG = True
LANGUAGE_COOKIE_DOMAIN = None
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
INSTALLED_APPS = 
LANGUAGES = 
COMMENTS_ALLOW_PROFANITIES = False
STATICFILES_DIRS = 
PREPEND_WWW = False
SECURE_PROXY_SSL_HEADER = None
LANGUAGE_COOKIE_AGE = None
SESSION_COOKIE_HTTPONLY = True
DEBUG_PROPAGATE_EXCEPTIONS = False
INTERNAL_IPS = 
CACHE_MIDDLEWARE_ALIAS = 'default'
MONTH_DAY_FORMAT = 'F j'
LOGIN_URL = '/accounts/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
TIME_FORMAT = 'P'
AUTH_USER_MODEL = 'auth.User'
DATE_INPUT_FORMATS = 
AUTHENTICATION_BACKENDS = 'django.contrib.auth.backends.ModelBackend'
EMAIL_HOST_PASSWORD = u'********************'
PASSWORD_RESET_TIMEOUT_DAYS = u'********************'
SESSION_FILE_PATH = None
AJAX_LOOKUP_CHANNELS = {'TableItemLookup': ('RESTO_App.lookup', 'ItemLookUp')}
SESSION_SAVE_EVERY_REQUEST = False
NUMBER_GROUPING = 0
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
CSRF_COOKIE_PATH = '/'
LOGIN_REDIRECT_URL = '/accounts/profile/'
DECIMAL_SEPARATOR = '.'
IGNORABLE_404_URLS = 
MIGRATION_MODULES = {}
TEMPLATE_STRING_IF_INVALID = ''
LOGOUT_URL = '/accounts/logout/'
EMAIL_USE_TLS = False
FIXTURE_DIRS = 
EMAIL_HOST = 'localhost'
DATE_FORMAT = 'N j, Y'
MEDIA_ROOT = ''
DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter'
ADMINS = 
FORMAT_MODULE_PATH = None
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
MEDIA_URL = ''
DATETIME_FORMAT = 'N j, Y, P'
TEMPLATE_DIRS = 
DISALLOWED_USER_AGENTS = 
ALLOWED_INCLUDE_ROOTS = 
LOGGING = {}
SHORT_DATE_FORMAT = 'm/d/Y'
AJAX_SELECT_INLINES = 'inline'
CACHE_MIDDLEWARE_KEY_PREFIX = u'********************'
TIME_ZONE = 'UTC'
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_SSL = False
TEMPLATE_CONTEXT_PROCESSORS = 
SESSION_COOKIE_AGE = 1209600
SETTINGS_MODULE = 'RESTO.settings'
USE_ETAGS = False
LANGUAGES_BIDI = 
FILE_UPLOAD_TEMP_DIR = None
CSRF_COOKIE_AGE = 31449600
STATIC_URL = '/static_resto/'
EMAIL_PORT = 25
USE_TZ = True
SHORT_DATETIME_FORMAT = 'm/d/Y P'
PASSWORD_HASHERS = u'********************'
ABSOLUTE_URL_OVERRIDES = {}
LANGUAGE_COOKIE_PATH = '/'
CACHE_MIDDLEWARE_SECONDS = 600
CSRF_COOKIE_HTTPONLY = False
DATETIME_INPUT_FORMATS = 
EMAIL_HOST_USER = ''
PROFANITIES_LIST = u'********************'

You're seeing this error because you have DEBUG = True in your
Django settings file. Change that to False, and Django will
display a standard 500 page.

Answer

alecxe picture alecxe · Feb 27, 2015

I think you are not using the latest version of django-ajax-selects package.

There was a related fix made in July 2014:

According to a changeset, mimetype was replaced by content_type.


Either run pip with an upgrade flag:

pip install --upgrade django-ajax-selects

or, install it directly from github:

git clone https://github.com/crucialfelix/django-ajax-selects.git
cd django-ajax-selects
python setup.py install