Skip to content

Django 4.2 issue related to is_ajax usage #228

@peteyb

Description

@peteyb

Hi 👋

On upgrade to Django 4.2 in our project and using django-selectable==1.4.0 a problem is present with the @ajax_required decorator where it is using the removed is_ajax method.

https://github.com/mlavin/django-selectable/blob/master/selectable/decorators.py#L44-L47

This was removed in Django 4.0 here https://docs.djangoproject.com/en/4.2/releases/4.0/#features-removed-in-4-0

Notes from Django 3.1 deprecation notice:

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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions