[Fixed]-'WSGIRequest' object has no attribute 'get'

27👍

You should use the request.POST dict-like object:

username = request.POST.get('username','')
password = request.POST.get('password','')

5👍

you should use this for Get method otherwise Post for post method in python 3

  username = request.GET.get('username','')
  password = request.GET.get('password','')

0👍

I was seeing this same error because I had written a decorator like this:

from functools import wraps

def require_authenticated(view_function):
    @wraps
    def wrapped(request, *args, **kwargs):
        if not request.user.is_authenticated:
            return JsonResponse({"detail": "User is not authenticated"}, status=403)
        return view_function(request, *args, **kwargs)
    return wrapped

The problem here is the way of using the functools.wraps builtin (which returns a decorator), the fix is to pass the view function to it, like this:

from functools import wraps

def require_authenticated(view_function):
    @wraps(view_function)  # <- this is the fix!
    def wrapped(request, *args, **kwargs):
        if not request.user.is_authenticated:
            return JsonResponse({"detail": "User is not authenticated"}, status=403)
        return view_function(request, *args, **kwargs)
    return wrapped

0👍

**value1=int(request.GET['num1'])
value2=int(request.GET['num2'])**

just use GET if you are using python version 3.9

0👍

If in case instead of putting your views.py‘s function in urls.py i.e

path('<urlsname>', views.<view_function>)

But you have wrote views.<form_class name> then also this error comes

-2👍

I had encountered the same issue. Try writing ‘GET’ instead of ‘get. Hope it solves.

username = request.GET('username','')
password = request.GET('password','')

Leave a comment