Code

Opened 4 years ago

Closed 4 years ago

#13695 closed (invalid)

Django Comments Loses Ajax Headers When Redirecting (request.is_ajax() === True --> request.is_ajax() === False)

Reported by: jacobstr Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If you redirect what was originally a request that:

request.is_ajax() === True

On the redirected page

request.is_ajax() === False

IMHO It should retain the Ajax headers. In my particular use case I'm submitting to django.contrib.comments via an ajax submission. I'm also providing the next parameter, hoping that my custom view can respond differently depending on whether or not the original form posting was Ajax or not (i.e. the comment form gracefully degrades to a non-ajax version if your js is borken). Unfortunately, the request never shows up as an Ajax request.

Attachments (0)

Change History (3)

comment:1 follow-up: Changed 4 years ago by r1cky

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

There is nothing django can do here. The initial and subsequent (after redirect) request are coming from the browser/client. The is_ajax method depends on an HTTP header (HTTP_X_REQUESTED_WITH) that apparently isn't getting set on the second request.

comment:2 in reply to: ↑ 1 Changed 4 years ago by anonymous

Replying to r1cky:

There is nothing django can do here. The initial and subsequent (after redirect) request are coming from the browser/client. The is_ajax method depends on an HTTP header (HTTP_X_REQUESTED_WITH) that apparently isn't getting set on the second request.

Yes. My instinct is that this was an oversight and not deliberate.

comment:3 Changed 4 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

I'm with r1cky -- this is a problem on the client side, not the server side.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.