Reputation: 1
Hi i started to make django and started with simple Hi app. But when i want to access on /hi/ i give error called "init() takes 1 positional argument but 2 were given"
Here is code
#urls.py
from django.contrib import admin
from django.urls import path
from hi.views import hiView
urlpatterns = [
path('admin/', admin.site.urls),
path('hi/', hiView),
]
#views.py
from django.shortcuts import render
from django.http import HttpRequest
def hiView(request):
return HttpRequest('Hi.')
#settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'hi',
]
im adding my directory list https://i.sstatic.net/IZWug.jpg
Upvotes: 0
Views: 533
Reputation: 80
You are trying to send a HttpRequest
instead of HttpResponse
.
The HttpRequest.__init__
method only takes one argument : self
, which is automatically passed by python when you create a new instance.
Upvotes: 2