django-hosts icon indicating copy to clipboard operation
django-hosts copied to clipboard

Automatically get parent_host from current visited host

Open fanckush opened this issue 7 years ago • 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: https://github.com/jazzband/django-hosts/blob/ad419905b80f73c627e14188c353e62280158c19/django_hosts/resolvers.py#L121

Any thoughts?

fanckush avatar Aug 28 '18 14:08 fanckush

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)()

LowerDeez avatar Mar 22 '21 14:03 LowerDeez