-1

I am working on a project using Django where I am creating a login authentication. I have created a function in Views.py (login) and I don't want to return anything, so I tried returning none. This yields an error, so what can I return instead?

Malte Schwerhoff
  • 12,684
  • 4
  • 41
  • 71
alakmar Shafin
  • 3,177
  • 2
  • 7
  • 17
  • 1
    Simply `return HttpResponse()` – JPG Jun 24 '20 at 08:03
  • Why do you want to use views in case you do not want to render anything on the template. Even in case you are processing some POST data or something like that you should redirect to some page or else do not create a view at all create a normal function in the same file – Amartya Gaur Jun 24 '20 at 08:04
  • no, I dont want to redirect I just want to be on that page even after successful login, Thanks For Help. – alakmar Shafin Jun 24 '20 at 08:06

2 Answers2

0

The view returns an HttpResponse object that contains the generated response. Each view function is responsible for returning an HttpResponse object.

Vishal Singh
  • 6,014
  • 2
  • 17
  • 33
0

view on django has default return

`from django.http import HttpResponse

    def my_view(request):
    return HttpResponse(status=201)`

visit docs for more info: https://docs.djangoproject.com/en/3.0/topics/http/views/

Prabesh Gouli
  • 413
  • 3
  • 11