Opened 8 years ago

Closed 7 years ago

#26079 closed New feature (wontfix)

add prefered/default protocol in the sites framework

Reported by: Eric Owned by: Eric
Component: contrib.sites Version: dev
Severity: Normal Keywords: sites protocol
Cc: Eric Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

I think adding a preferred/default protocol in the sites framework would be a great addition for generating full url's to django websites.

specially when generating url from action not coming from a request like the sitemaps ping_google that assumes the protocol to be http:

    current_site = Site.objects.get_current()
    url = "http://%s%s" % (current_site.domain, sitemap_url)

so we could have something like this instead:

    current_site = Site.objects.get_current()
    url = "%s://%s%s" % (current_site.protocol, current_site.domain, sitemap_url)

and maybe even add a shortcut for the site's base url

Attachments (1)

sites.patch (951 bytes ) - added by Eric 8 years ago.
proposed changes

Download all attachments as: .zip

Change History (7)

by Eric, 8 years ago

Attachment: sites.patch added

proposed changes

comment:1 by Eric, 8 years ago

Owner: changed from nobody to Eric
Status: newassigned

comment:2 by Eric, 8 years ago

Needs tests: set
Patch needs improvement: set

this is just a proposition, if the feedback seems positive I will make all proper tests and Documentation

Last edited 8 years ago by Eric (previous) (diff)

comment:3 by Tim Graham, 8 years ago

Description: modified (diff)

I'm not immediately convinced that a database field is the way to go for a couple reasons:

  1. It would make data less portable between development (where SSL is often not in use) and production.
  2. I'm not sure it's a common case that only some sites would use SSL but not others.

A third-party library called django-hosts, which djangoproject.com uses, adds a setting called HOSTS_SCHEME to solve this. I think there's been some discussion about merging at least parts of this library into core since it solves common problems.

See also #10944 (we might close this ticket as a duplicate of that one) and #23829 (about customizing ping_google to allow https). I think the best course of action would be to consider this feedback and write to the DevelopersMailingList with your proposal. Either solution of a new setting or a new database field need feedback from a wider audience. Thanks!

comment:5 by Tim Graham, 8 years ago

Triage Stage: UnreviewedSomeday/Maybe

comment:6 by Tim Graham, 7 years ago

Resolution: wontfix
Status: assignedclosed

Closing in absence of consensus on the mailing list.

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