8👍
Put this import in your poll/views.py before using HttpResponse.
from django.http import HttpResponse
- How to downgrade from Django 1.7 to Django 1.6
- What is the difference between the create and perform_create methods in Django rest-auth
- What is a good Django workflow?
- Migrate datetime w. timezone in PostgreSQL to UTC timezone to use Django 1.4
4👍
from django.http import HttpResponse
add this line on the top of polls/views.py file. I am new too, and had the same error. good Luck and i see u around.
- One project, Multiple customers with git?
- ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'
- Django admin.TabularInline auto insert three blank row
- Django 'ascii' codec can't encode character
- How to test a Django on_commit hook without clearing the database?
1👍
in your polls/views.py
By default is :
from django.shortcuts import render
change to:
from django.shortcuts import render,HttpResponse
this will call the HttpResponse class
- Using Django's built in web server in a production environment
- How to check whether virtualenv was created with '–no-site-packages'?
- How to assign to a Django PointField model attribute?
0👍
I had imported HttpResponse
and still got this error.
If you use Apache server as your primary server for web, try restarting Apache and reloading the page.
- Passing list of values to django view via jQuery ajax call
- Django ForeignKey limit_choices_to a different ForeignKey id
0👍
In my case the import was there, but when I called HttpsResponse I called it with small h as a typo instead of the capital H
from django.http import HttpResponse
def home(request):
return HttpResponse("Hello!") #==> This one was with httpResponse so the same error been received.
- Spurious newlines added in Django management commands
- How to remove Add button in Django admin, for specific Model?
- Static files won't load when out of debug in Django
- Django order items by two fields, but ignoring them if they're zero
- How to use Django variable in JavaScript file?
- How to use pytest fixtures with django TestCase
- Django cms – invalid block tag endblock
-1👍
- Check your import statement.
- Check your function. I had “HttpsResponse” instead of “HttpResponse”
Good luck.
- Django widget override template
- How to have a "random" order on a set of objects with paging in Django?
- Provide tab title with reportlab generated pdf
Source:stackexchange.com