Django

Code

Ticket #4685 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: cbrand@redback.com Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords:
Cc: treborhudson@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

check_protocol.diff (0.7 kB) - added by treborhudson@gmail.com on 06/27/07 13:43:51.
Patch attempt, needs testing
check_protocol.2.diff (0.9 kB) - added by Jeff Hilyard <jhilyard@uga.edu> on 06/27/07 16:33:55.
Added startswith("https://") check

Change History

06/27/07 13:43:51 changed by treborhudson@gmail.com

  • attachment check_protocol.diff added.

Patch attempt, needs testing

06/27/07 13:46:15 changed by Rob Hudson <treborhudson@gmail.com>

  • cc set to treborhudson@gmail.com.
  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests set to 1.
  • needs_docs changed.

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.

06/27/07 14:01:08 changed by cbrand@redback.com

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

06/27/07 14:21:21 changed by Rob Hudson <treborhudson@gmail.com>

  • needs_tests deleted.

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

06/27/07 16:33:55 changed by Jeff Hilyard <jhilyard@uga.edu>

  • attachment check_protocol.2.diff added.

Added startswith("https://") check

07/03/07 10:11:50 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #4685 ("View on site" links in admin don't work for an https site)




Change Properties
Action