init () получил неожиданный аргумент ключевого слова "mimetype"
Я использую Django 1.7.4 и django_ajax_selects для автозаполнения.
поиск не удается, и я получаю эту ошибку:
_ _ init__ () получил неожиданный аргумент ключевого слова 'mimetype'
полная трассировка стека, как показано ниже. Что я могу сделать, чтобы устранить эту ошибку?
нормально ли, что GET вызывается вместо POST. Делает ли django_ajax_select получение, а не сообщение?
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 FoundationApache2.2binhttpd.exe
Python Version: 2.7.6
Python Path: ['C:Python27libsite-packagessetuptools-2.0.1-py2.7.egg', 'C:Python27libsite-packagesdjango_debug_toolbar-0.11.0-py2.7.egg', 'C:Python27libsite-packagesrequests-2.2.1-py2.7.egg', 'C:Python27libsite-packagessuds_jurko-0.6-py2.7.egg', 'C:Python27libsite-packageselaphe-0.6.0-py2.7.egg', 'C:Python27libsite-packagespillow-2.3.0-py2.7-win32.egg', 'C:Python27libsite-packagesghostscript-0.5dev-py2.7.egg', 'C:Python27libsite-packagessouth-0.8.3-py2.7.egg', 'C:Python27libsite-packagescrochet-1.0.0-py2.7.egg', 'C:Python27libsite-packagesdjango_ajax_selects-1.3.4-py2.7.egg', 'C:Python27libsite-packagesscrapy-0.22.2-py2.7.egg', 'C:Python27libsite-packagessix-1.7.2-py2.7.egg', 'C:Python27libsite-packagescssselect-0.9.1-py2.7.egg', 'C:Python27libsite-packagespyopenssl-0.14-py2.7.egg', 'C:Python27libsite-packagesqueuelib-1.1.1-py2.7.egg', 'C:Python27libsite-packagesw3lib-1.6-py2.7.egg', 'C:Python27libsite-packagespython_dateutil-1.5-py2.7.egg', 'C:Python27libsite-packagesmemory_profiler-0.32-py2.7.egg', 'C:Python27libsite-packagescython-0.21.1-py2.7-win32.egg', 'C:Python27libsite-packagesline_profiler-1.0-py2.7-win32.egg', 'C:Python27libsite-packagespika-0.9.14-py2.7.egg', 'C:Python27libsite-packagespyws-1.1.5-py2.7.egg', 'C:Python27libsite-packagesnose-1.3.4-py2.7.egg', 'C:Python27libsite-packagesjinja2-2.7.3-py2.7.egg', 'C:Python27libsite-packageshttplib2-0.9-py2.7.egg', 'C:Python27libsite-packagesargparse-1.3.0-py2.7.egg', 'C:Python27libsite-packagesmarkupsafe-0.23-py2.7-win32.egg', 'C:Python27libsite-packagessoapfish-0.6dev-py2.7.egg', 'C:Python27libsite-packagessoapbox-0.3.8.dev-py2.7.egg', 'C:Python27libsite-packagesnum2words-0.5.2-py2.7.egg', 'C:Python27libsite-packagesunidecode-0.04.17-py2.7.egg', 'C:Windowssystem32python27.zip', 'C:Python27Lib', 'C:Python27DLLs', 'C:Python27Liblib-tk', 'C:Apache Software FoundationApache2.2', 'C:Apache Software FoundationApache2.2bin', 'C:Python27', 'C:Python27libsite-packages', 'C:Python27libsite-packagesPIL', 'C:Python27libsite-packageswin32', 'C:Python27libsite-packageswin32lib', 'C:Python27libsite-packagesPythonwin', '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:Python27libsite-packagesdjangocorehandlersbase.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:Python27libsite-packagesdjango_ajax_selects-1.3.4-py2.7.eggajax_selectviews.py" in ajax_lookup
47. return HttpResponse(results, mimetype='application/javascript')
File "C:Python27libsite-packagesdjangohttpresponse.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 FoundationApache2.2htdocsautocompletelookupajax_lookupTableItemLookup'
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:Windowssystem32cmd.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:RESTOstaticfiles'
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.
2 ответов
Я думаю, что вы не используете последнюю версию django-ajax-selects
пакета.
в июле 2014 года было сделано соответствующее исправление:
по словам изменений, mimetype
был заменен content_type
.
либо run pip
С флагом обновления:
pip install --upgrade django-ajax-selects
или установить его прямо из github:
git clone https://github.com/crucialfelix/django-ajax-selects.git
cd django-ajax-selects
python setup.py install
в Django 1.6 HttpResponse похож на
if mimetype:
warnings.warn("Using mimetype keyword argument is deprecated, use"
" content_type instead",
DeprecationWarning, stacklevel=2)
content_type = mimetype
мы просто предупреждаем и назначаем mimetype content_type.
в Django 1.8 мы не используем mimetype. Вместо этого мы присваиваем значение типа "image / png"и т. д.. в content_type. Просто сухая концепция.
my_file = open('newimage.jpg','rb').read()
return HttpResponse(my_file, content_type = "image/png")