16👍
If you have a request object,do
request.META['HTTP_HOST']
This would return the hostname
9👍
If you’re using django.contrib.sites
framework:
from django.contrib.sites.models import Site
your_domain = Site.objects.get_current().domain
Reference: https://docs.djangoproject.com/en/1.8/ref/contrib/sites/
- Django Boolean Queryset Filter Not Working
- Django Views: When is request.data a dict vs a QueryDict?
- Django: prefetch related objects of a GenericForeignKey
- Disable a specific Django middleware during tests
- Django signals, how to use "instance"
0👍
import platform
platform.node()
from the docs:
“Returns the computer’s network name (may not be fully qualified!). An
empty string is returned if the value cannot be determined.”
- Django rest framework create user with password
- Invalid HTTP_HOST header: The domain name provided is not valid — requests to dockerized django app using container name
Source:stackexchange.com