Opened 9 years ago

Closed 9 years ago

#4685 closed (fixed)

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

Reported by: cbrand@… Owned by: adrian
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: UI/UX:


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@… 9 years ago.
Patch attempt, needs testing
check_protocol.2.diff (957 bytes) - added by Jeff Hilyard <jhilyard@…> 9 years ago.
Added startswith("https://") check

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by treborhudson@…

Patch attempt, needs testing

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

  • Cc treborhudson@… added
  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

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 9 years ago by cbrand@…

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

comment:3 Changed 9 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 9 years ago by Jeff Hilyard <jhilyard@…>

Added startswith("https://") check

comment:4 Changed 9 years ago by adrian

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

(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