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','')
- Django-admin.py startproject opens notepad, instead of creating a project
- UnicodeEncodeError:'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
- Making Twitter, Tastypie, Django, XAuth and iOS work to Build Django-based Access Permissions
- How can I automatically let syncdb add a column (no full migration needed)
- How to install pygments on Ubuntu?
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
- Django ForeignKey limit_choices_to a different ForeignKey id
- Appropriate choice of authentication class for python REST API used by web app
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
- How to get object from PK inside Django template?
- Django; AWS Elastic Beanstalk ERROR: Your WSGIPath refers to a file that does not exist
- Django migrate and makemigrate automatic yes on prompt
- How to specify which eth interface Django test server should listen on?
-2👍
I had encountered the same issue. Try writing ‘GET’ instead of ‘get. Hope it solves.
username = request.GET('username','')
password = request.GET('password','')
- Accessing form fields as properties in a django view
- Django OneToOneField with possible blank field
- How to store django objects as session variables ( object is not JSON serializable)?
- How to upgrade Django on ubuntu?
Source:stackexchange.com