Я обновил django и все приложения, которые я использовал для последней версии, но из-за огромных изменений, сделанных между djangorestframework 0.4.0 и 3.3.0, я вернулся к 0.4.0 и решил исправить простой вопрос он импортирует JSON из django.utils
и редактировать его import json
теперь я получаю сообщение об ошибке templatedoesnotexistРабота с djangorestframework 0.3.0 и django 1.7
Environment:
Request Method: GET
Request URL: http://kbuzz.webfactional.com/rest/movies/?device=browser
Django Version: 1.7.10
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.redirects',
'django.contrib.humanize',
'autocomplete_light',
'rest_framework',
'haystack',
'lamusoftware.generic',
'mptt',
'bootstrapform',
'sorl.thumbnail',
'oauth2client',
'articles',
'banners',
'common',
'directory',
'events',
'galleries',
'marketplace',
'movies',
'pages',
'profiles',
'search',
'stats',
'minidetector',
'mobile',
'reports',
'favorites',
'braces',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'widget_tweaks',
'wordofmouth',
'ckeditor',
'django_mobile',
'debug_toolbar',
'markup_deprecated')
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.contrib.redirects.middleware.RedirectFallbackMiddleware',
'minidetector.Middleware',
'mobileesp.middleware.MobileDetectionMiddleware',
'kb.middleware.log_ip_middleware.SetRemoteAddrFromForwardedFor',
'kb.middleware.log_ip_middleware.RedirectMovie')
Template Loader Error:
Django tried loading these templates, in this order:
Using loader django_mobile.loader.Loader:
Using loader django.template.loaders.filesystem.Loader:
/home/kbuzz/webapps/kenyabuzz/kb/kb/templates/djangorestframework/api.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/contrib/auth/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/contrib/sitemaps/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/contrib/admin/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/autocomplete_light/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/rest_framework/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/lib/python2.7/haystack/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/mptt/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/lib/python2.7/bootstrapform/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/kenyabuzz/kb/reports/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/kenyabuzz/kb/favorites/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/allauth/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/allauth/socialaccount/providers/facebook/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/kenyabuzz/kb/wordofmouth/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/lib/python2.7/ckeditor/templates/djangorestframework/api.html (File does not exist)
/home/kbuzz/webapps/django/lib/python2.7/debug_toolbar/templates/djangorestframework/api.html (File does not exist)
Traceback:
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/views/decorators/csrf.py" in wrapped_view
57. return view_func(*args, **kwargs)
File "/home/kbuzz/lib/python2.7/djangorestframework/views.py" in dispatch
246. return self.final(request, response, *args, **kwargs)
File "/home/kbuzz/lib/python2.7/djangorestframework/views.py" in final
199. return self.render(response)
File "/home/kbuzz/lib/python2.7/djangorestframework/mixins.py" in render
251. content = renderer.render(response.cleaned_content, media_type)
File "/home/kbuzz/lib/python2.7/djangorestframework/renderers.py" in render
342. template = loader.get_template(self.template)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/template/loader.py" in get_template
144. template, origin = find_template(template_name, dirs)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/template/loader.py" in find_template
136. raise TemplateDoesNotExist(name)
Exception Type: TemplateDoesNotExist at /rest/movies/
Exception Value: djangorestframework/api.html
UPDATE
отредактированные файл настройки из rest_framework
в djangorestframework
теперь г tting этот тип ошибки ошибки должен быть удален для httpresponse.
Окружающая среда:
Request Method: GET
Request URL: http://kbuzz.webfactional.com/rest/movies/categories/?device=browser
Django Version: 1.7.10
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.redirects',
'django.contrib.humanize',
'autocomplete_light',
'djangorestframework',
'haystack',
'lamusoftware.generic',
'mptt',
'bootstrapform',
'sorl.thumbnail',
'oauth2client',
'articles',
'banners',
'common',
'directory',
'events',
'galleries',
'marketplace',
'movies',
'pages',
'profiles',
'search',
'stats',
'minidetector',
'mobile',
'reports',
'favorites',
'braces',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'widget_tweaks',
'wordofmouth',
'ckeditor',
'django_mobile',
'debug_toolbar',
'markup_deprecated')
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.contrib.redirects.middleware.RedirectFallbackMiddleware',
'minidetector.Middleware',
'mobileesp.middleware.MobileDetectionMiddleware',
'kb.middleware.log_ip_middleware.SetRemoteAddrFromForwardedFor',
'kb.middleware.log_ip_middleware.RedirectMovie')
Traceback:
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/views/decorators/csrf.py" in wrapped_view
57. return view_func(*args, **kwargs)
File "/home/kbuzz/lib/python2.7/djangorestframework/views.py" in dispatch
246. return self.final(request, response, *args, **kwargs)
File "/home/kbuzz/lib/python2.7/djangorestframework/views.py" in final
199. return self.render(response)
File "/home/kbuzz/lib/python2.7/djangorestframework/mixins.py" in render
256. resp = HttpResponse(content, mimetype=response.media_type, status=response.status)
File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/http/response.py" in __init__
318. super(HttpResponse, self).__init__(*args, **kwargs)
Exception Type: TypeError at /rest/movies/categories/
Exception Value: __init__() got an unexpected keyword argument 'mimetype'
Спасибо, что удалили эту ошибку сейчас, я получаю разные, пожалуйста, посмотрите мое обновление –
mimetype в этой строке приводит к ошибке resp = HttpResponse (content, mimetype = response.media_type, status = response.status) –
Это должно быть 'content_type', а не' mimetype' в Django 1.5+. Django rest framework 0.4.0 был выпущен в 2012 году. Я не думаю, что это хорошая идея попробовать использовать его с Django 1.7, который был выпущен два года спустя. Я не могу помочь вам исправить все ошибки, возникающие при попытке заставить его работать. – Alasdair