It seems Request.is_xhr is deprecated. Getting warnings here... How do we fix this?
flask.jsonify(**{...})
File "/usr/local/lib/python2.7/site-packages/flask/json.py", line 251, in jsonify
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
File "/usr/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 689, in is_xhr
), stacklevel=2)
DeprecationWarning: Request.is_xhr is deprecated. Given that the X-Requested-With header is not a part of any spec, it is not reliable
That depends on what you are using it for. And since this is not a place to ask for help but an issue tracker, please ask this question in the #pocoo IRC channel on freenode or on Stack Overflow.
@ThiefMaster Maybe I didn't make myself clear here. This is an issue with Flask. It should not be accessing Request.is_xhr. So this needs fixing so that Flask does not access Request.is_xhr.
Or am I totally misunderstanding?
Oh indeed, I didn't notice it's coming from within Flask. As a workaround on your side, simply disable JSONIFY_PRETTYPRINT_REGULAR or ignore the warning for now.
Master already removed this.
Sweet, thank you!
/home/vicente/.local/lib/python3.6/site-packages/werkzeug/local.py:347: DeprecationWarning: Request.is_xhr is deprecated. Given that the X-Requested-With header is not a part of any spec, it is not reliable
return getattr(self._get_current_object(), name)
Still getting this when using jsonify with flask, with python 3.6 :(
Anyone having the same issue?
@KoJoVe this was fixed in master but there was no release since. Until next Flask version is released, you may disable JSONIFY_PRETTYPRINT_REGULAR as a workaround as suggested above.
Oh, I did not understood that there was no releases since then. Thank you very much!
This now completely breaks for me using 0.10.1 Flask (as of today). 0.12.4 did have the option of disabling request.is_xhr through the JSONIFY_PRETTYPRINT_REGULAR.
Complete error for other poor souls who might eventually get here like I did;
AttributeError: 'Request' object has no attribute 'is_xhr'
@AndySeymour2904 I am using the same version as you,
I Fixed using workaround not a permanent fix.
Its breaking at the line in file lib/python3.8/site-packages/flask/json.py
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
The request.is_xhr is not present & giving trouble.
Just set value of JSONIFY_PRETTYPRINT_REGULAR = False
So it will not go in AND condition itself.
The problem is because flask doesn't lock it's dependencies. https://github.com/pallets/flask/blob/0.12.x/setup.py#L74 It installs Werkzeug>=0.7 and Wekzeug 1.0(released today, Feb 7) removes this function. Fix is to add Werkzeug==0.16.1 to your requirements.txt
Most helpful comment
The problem is because flask doesn't lock it's dependencies. https://github.com/pallets/flask/blob/0.12.x/setup.py#L74 It installs
Werkzeug>=0.7and Wekzeug 1.0(released today, Feb 7) removes this function. Fix is to add Werkzeug==0.16.1 to your requirements.txt