1👍
✅
No, you can’t assign anything in an if
test expression.
If you didn’t have the rest of the if
block,
id = request.POST and request.POST.get('id')
would work.
It doesn’t make much sense, to do it, though, because id = request.POST.get('id')
works just fine with empty request.POST
.
Please remember that request.POST
can be empty, even if the method was POST
. This is what most people would write:
if request.method == 'POST':
id = request.POST.get('id')
# rest of block
- [Answer]-In a Django web application, would large files or many unnecessary import statements slow down my server?
- [Answer]-How to change private S3 bucket setting to serve images as http (not https) with django-storages?
- [Answer]-Django: using the URL request as the name of a model's field
Source:stackexchange.com