Opened 17 years ago

Closed 17 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: dev
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

Description

This was mentioned as a side-note in http://code.djangoproject.org/ticket/634.
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/defaults.py :
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@… 17 years ago.
Patch attempt, needs testing
check_protocol.2.diff (957 bytes ) - added by Jeff Hilyard <jhilyard@…> 17 years ago.
Added startswith("https://") check

Download all attachments as: .zip

Change History (6)

by treborhudson@…, 17 years ago

Attachment: check_protocol.diff added

Patch attempt, needs testing

comment:1 by Rob Hudson <treborhudson@…>, 17 years ago

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

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

comment:3 by Rob Hudson <treborhudson@…>, 17 years ago

Needs tests: unset

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

by Jeff Hilyard <jhilyard@…>, 17 years ago

Attachment: check_protocol.2.diff added

Added startswith("https://") check

comment:4 by Adrian Holovaty, 17 years ago

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