Opened 12 years ago

Closed 12 years ago

#4685 closed (fixed)

"View on site" links in admin don't work for an https site

Reported by: cbrand@… Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: Keywords:
Cc: treborhudson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This was mentioned as a side-note in
My site is entirely served through https.
When I added get_absolute_url() methods to my models, the "view on site" links appeared in the admin, as expected. Although they initially go to an https location (with "r" and some numbers), that then redirects to an http link, which doesn't work. If it used "https:" instead of "http:", it would work.

The problem seems to be the hard-coded "http" at line 64 of django/views/ :
return http.HttpResponseRedirect('http://%s%s' % (object_domain, absurl))

I don't know how to figure out whether "http" or "https" is appropriate, or I'd submit a patch...

Attachments (2)

check_protocol.diff (669 bytes) - added by treborhudson@… 12 years ago.
Patch attempt, needs testing
check_protocol.2.diff (957 bytes) - added by Jeff Hilyard <jhilyard@…> 12 years ago.
Added startswith("https://") check

Download all attachments as: .zip

Change History (6)

Changed 12 years ago by treborhudson@…

Attachment: check_protocol.diff added

Patch attempt, needs testing

comment:1 Changed 12 years ago by Rob Hudson <treborhudson@…>

Cc: treborhudson@… added
Has patch: set
Needs tests: set

I just happened to see the same check in sitemaps so I made a patch. I don't have an easy way to test this so I'm hoping cbrand can test. I'm adding myself to the CC list to be notified. Thanks.

comment:2 Changed 12 years ago by cbrand@…

I applied that patch to my (0.96) tree and it fixes the problem.
Thanks !

comment:3 Changed 12 years ago by Rob Hudson <treborhudson@…>

Needs tests: unset

I tested in a non-https site and it didn't break anything. I'm going to unflag "needs tests".

Changed 12 years ago by Jeff Hilyard <jhilyard@…>

Attachment: check_protocol.2.diff added

Added startswith("https://") check

comment:4 Changed 12 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [5594]) Fixed #4685 -- 'View on site' now works for https URLs. Thanks, cbrand@…, treborhudson@…, Jeff Hilyard

Note: See TracTickets for help on using tickets.
Back to Top