python - No module named http_client error when trying to run django with django rest framework -
i trying create simple api using django rest framework. in view have following code.
django.shortcuts import render moviestash.models import movie moviestash.serializer import movieserializer rest_framework import generics #list movies , add movies class movielist(generics.listcreateapiview): queryset = movie.objects.all() serializer_class = movieserializer #get movie , delete movie class moviedetail(generics.retrievedestroyapiview): queryset = movie.objects.all() serializer_class = movieserializer
when run server , try go url following error.
request method: request url: http://127.0.0.1:8000/ django version: 1.6 python version: 2.7.0 installed applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'moviestash', 'south', 'rest_framework') installed middleware: ('django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware') traceback: file "n:\python\venvs\rest_api\lib\site-packages\django\core\handlers\base.py" in get_response 101. resolver_match = resolver.resolve(request.path_info) file "n:\python\venvs\rest_api\lib\site-packages\django\core\urlresolvers.py" in resolve 318. pattern in self.url_patterns: file "n:\python\venvs\rest_api\lib\site-packages\django\core\urlresolvers.py" in url_patterns 346. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) file "n:\python\venvs\rest_api\lib\site-packages\django\core\urlresolvers.py" in urlconf_module 341. self._urlconf_module = import_module(self.urlconf_name) file "n:\python\venvs\rest_api\lib\site-packages\django\utils\importlib.py" in import_module 40. __import__(name) file "n:\python\movies_api\movies_api\urls.py" in <module> 10. url(r'^movies/', include('moviestash.urls')), file "n:\python\venvs\rest_api\lib\site-packages\django\conf\urls\__init__.py" in include 26. urlconf_module = import_module(urlconf_module) file "n:\python\venvs\rest_api\lib\site-packages\django\utils\importlib.py" in import_module 40. __import__(name) file "n:\python\movies_api\moviestash\urls.py" in <module> 3. . import views file "n:\python\movies_api\moviestash\views.py" in <module> 4. rest_framework import generics file "n:\python\venvs\rest_api\lib\site-packages\rest_framework\generics.py" in <module> 8. rest_framework import views, mixins file "n:\python\venvs\rest_api\lib\site-packages\rest_framework\views.py" in <module> 14. rest_framework.response import response file "n:\python\venvs\rest_api\lib\site-packages\rest_framework\response.py" in <module> 8. django.utils.six.moves.http_client import responses exception type: importerror @ / exception value: no module named http_client
when go django shell , can perform following import no issue django.utils.six.moves import http_client. after import http_client performed dir(http_client) , can see responses object, reason when try import using django.utils.six.moves.http_client import responses importerror: no module named http_client. frustrating least.
it looks hitting issue 2969. should work if upgrade django 1.6 1.6.11. however, please note 1.6 end of life , not receive security fixes, ideally should upgrade latest supported version of django or latest lts.
Comments
Post a Comment