Code

Opened 2 years ago

Closed 17 months ago

Last modified 17 months ago

#18558 closed New feature (fixed)

Supply `url` property to `HttpResponseRedirect` and `HttpResponsePermanentRedirect`

Reported by: coolRR Owned by: claudep
Component: HTTP handling Version: master
Severity: Normal Keywords:
Cc: hirokiky@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by jezdez)

Currently the way to get the URL that a HttpResponseRedirect is redirecting to requires doing response['Location']. This is not so intuitive. There's no reason to remember the HTML header name when dealing with a redirect response.

Instead I propose this property:

url = property(lambda self: self['Location'])

Attachments (0)

Change History (11)

comment:1 Changed 2 years ago by coolRR

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

Sorry for the butchered Python, I meant:

    url = property(lambda self: self['Location'])

comment:2 Changed 2 years ago by jezdez

  • Description modified (diff)
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature

Formatting updates.

comment:3 Changed 2 years ago by coolRR

What is needed now to add this to Django?

comment:4 Changed 18 months ago by hirokiky

  • Cc hirokiky@… added

https://github.com/django/django/pull/657

I opened a pull-request. Fixed the implementation and tests.

comment:5 Changed 18 months ago by claudep

  • Needs documentation set
  • Patch needs improvement set

comment:6 Changed 18 months ago by hirokiky

  • Owner changed from nobody to hirokiky
  • Status changed from new to assigned

comment:7 Changed 17 months ago by anonymous

  • Needs documentation unset
  • Patch needs improvement unset

I added the documentaiton and tests.

comment:8 Changed 17 months ago by claudep

  • Owner changed from hirokiky to claudep
  • Triage Stage changed from Accepted to Ready for checkin

comment:9 Changed 17 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In e94f405d9499d310ef58b7409a98759a5f5512b0:

Fixed #18558 -- Added url property to HttpResponseRedirect*

Thanks coolRR for the report.

comment:10 Changed 17 months ago by hirokiky

Thanks coolRR and claudep.
I am glad to contribute to Django at first time.

comment:11 Changed 17 months ago by coolRR

Thank you hirokiky and claudep!

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.