jazzband/django-hosts

Automatically get parent_host from current visited host

fanckush opened this issue · 1 comments

The reverse() (and {% url ...%}) in django use the same domain name from the user request. shouldn't the reverse() function (and {% host_url ... %}) act the same without needing to hard code the PARENT_HOST is the settings

I think the change needs to be around here:

if parent_host:

Any thoughts?

Very inefficient solution:

  from django.utils.functional import lazy

  def parent_host():
      from django.contrib.sites.models import Site
      site = Site.objects.get_current()
      return site.domain

  PARENT_HOST = lazy(parent_host, str)()