Django Import Error when running templates - django

I am getting this error when I use templates:
ImportError: No module named templates.backends.django
If I use an HttpResponse the page shows up, but I get this error with the render function.
views.py:
from django.shortcuts import render
def login(request):
return render(request,'/test.html')
I'm using python 2.7.12

Related

I just setup python django and Im unable to import

I just finished installing Python and Django. I followed everything in a tutorial video and I wrote the most simple code:
from django.shortcuts import render
from django.http import HttpResponse
def hello(request):
return HttpResponse("<h1>Hello world!</h1>")
I imported it to the URL and it works as expected but the problem is I get this error:Unable to import I don't know why it is saying this because it works well. what is wrong with the program?
And I have the same import problem on other files too.

I got ImportError and cannot import name Httpresponse from django

I am trying to build a website and I got this error:
ImportError: cannot import name 'Httpresponse' from 'django.http' (C:\Users\vivek\Envs\asvc\lib\site-packages\django\http\__init__.py)
I even tried from django.http
Python is case sensitive, so even though there's no misspelling, the correct sentence would be
from django.http import HttpResponse

Google App Engine import error, for django.urls

I'm trying to learn Django, so I completed their multi-part tutorial (Python 2.7) and ran it locally. I got it working fine on my PC.
I need the following import, in a views.py file:
from django.urls import reverse
When I upload it to GAE, it gives me the following error:
Exception Type: ImportError
Exception Value: No module named urls
Is this module unavailable for the GAE, or am I doing something wrong?
(By the way, I need this import so I can use the "reverse" method, after a user submission is received in the polls app, like: HttpResponseRedirect(reverse('polls:results', args=(question.id,))) )
reverse() was moved from django.core.urlresolvers to django.urls in Django 1.10. The error suggests that you are using an older version of Django.
You need to import reverse() from the old location:
from django.core.urlresolvers import reverse

django-disqus with django 1.4.8

I'm receiving this error when I add disqus to the INSTALLED_APP:
Error: No module named urllib.parse
I tracked this down to the following line:
from django.utils.http import urlencode
from django.utils.six.moves.urllib.error import URLError
from django.utils.six.moves.urllib.request import (
ProxyHandler,
Request,
urlopen,
build_opener,
install_opener
)
I know that six.moves is not included with django 1.4.8, is there any substitute?
Thanks
Six is an external library, which Django includes for convenience.
You could try installing six separately, and change the imports, for example change
from django.utils.six.moves.urllib.error import URLError
to
from six.moves.urllib.error import URLError

Django class based views - no module named base

I'm having a problem trying to use class based views in django.
When I try to import the base View I get an import error.
I've simplified my view down to the exact same code as used in the documentation:
from django.http import HttpResponse
from django.views.base import View
class MyView(View):
def get(self, request):
# <view logic>
return HttpResponse('result')
The error I'm getting is
ImportError at /myurl/
No module named base
urls.py are fine and Django is definitely version 1.5 - I've completely reinstalled it with pip, any ideas?
Because of #dm03514 comment I test it. I try your code in your question and I got the same error with you "No module named base". So when I change it to, like the codes below, it works and no error.
from django.views.generic.base import View
Try before judging, I will accept it if it is wrong and I will try to fix it.