This question already has an answer here:
Firstly, I want to say that I'm a beginner in Django.
I'm looking for a simple way to retrieve the domain name of my Django website.
I want to do this in my settings.py. I've already tried with the socket something like this:
socket.gethostname()
but this doesn't work correctly.
from the docs:
If you're using
django.contrib.sites
framework:Reference: https://docs.djangoproject.com/en/1.8/ref/contrib/sites/
If you have a request object,do
This would return the hostname