-
Notifications
You must be signed in to change notification settings - Fork 98
Description
What happened?
after enabling ALLOCATION_ACCOUNT_ENABLED and supplying an entry for ALLOCATION_ACCOUNT_MAPPING,
I get the following:
in the browser: "We're having a bit of system trouble at the moment. Please check back soon!"
in the logs: AttributeError: 'WSGIRequest' object has no attribute 'is_ajax'
A little research shows that the method HttpRequest.is_ajax() was deprecated in django 3.1 and removed in django 4.0. pyproject.toml shows django 4.2 is required.
https://docs.djangoproject.com/en/4.0/releases/4.0/
Version
1.1.7
Component
Allocations
What browsers are you seeing the problem on?
None
Relevant log output
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/views/generic/edit.py", line 184, in post
return super().post(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/views/generic/edit.py", line 153, in post
return self.form_valid(form)
^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/coldfront/core/allocation/views.py", line 1660, in form_valid
if self.request.is_ajax():
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WSGIRequest' object has no attribute 'is_ajax'
Tasks/ user tests when bug is fixed
details for how to fix the issue can be found in the django 3.1 release notes:
The HttpRequest.is_ajax() method is deprecated as it relied on a jQuery-specific way of signifying AJAX calls, while current usage tends to use the JavaScript Fetch API. Depending on your use case, you can either write your own AJAX detection method, or use the new HttpRequest.accepts() method if your code depends on the client Accept HTTP header.
If you are writing your own AJAX detection method, request.is_ajax() can be reproduced exactly as request.headers.get('x-requested-with') == 'XMLHttpRequest'.
https://docs.djangoproject.com/en/4.0/releases/3.1/#deprecated-features-3-1