0

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.stack.imgur.com/IZWug.jpg

nakinfk
  • 1
  • 2

1 Answers1

1

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.

Abdul Aziz Barkat
  • 19,475
  • 3
  • 20
  • 33
Trivial
  • 45
  • 1
  • 2