0

I downloaded a HTML template form and used in my HTML page and getting the data from it.

The function in the view.py associated with it is working.

request.POST.get('name') is returning the text inputted but gives the error on the redirect page.

Function in views.py

def login(request):
    if request.method == "POST":
        email = request.POST.get('email')
        password = request.POST.get('pass')
        print(email)
        print(password)
        return redirect
    return render(request, 'taskManagementWebApp_templates/login.html')

Terminal Output when clicked on Button

abc@gmail.com
123456789
Internal Server Error: /login/
Traceback (most recent call last):
  File "C:\Users\Akestech\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\Akestech\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\deprecation.py", line 96, in __call__
    response = self.process_response(request, response)
  File "C:\Users\Akestech\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\middleware\clickjacking.py", line 26, in process_response
    if response.get('X-Frame-Options') is not None:
AttributeError: 'function' object has no attribute 'get'
[16/Oct/2019 12:16:55] "POST /login/ HTTP/1.1" 500 60650

Error on Webrowser Screenshot of Error during the calling of redirect

2 Answers 2

1

return redirect

This line is not valid.

redirect should be something like this:

redirect(to, *args, permanent=False, **kwargs)

Where to could be:

  1. A model: the model’s get_absolute_url() function will be called.
  2. A view name, possibly with arguments: reverse() will be used to reverse-resolve the name.
  3. An absolute or relative URL, which will be used as-is for the redirect location.

Have a look at the Django's official documentation and update it according to your needs.

0

You are returning redirect, which is a function that creates a redirect response.

You have to call it and return the result, e.g.

return redirect("/some-path/")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.