django-hosts
django-hosts copied to clipboard
Automatically get parent_host from current visited host
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?
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)()