Django 3.2, Python 3.7, Windows 10.
try:
from django.contrib.sites.shortcuts import get_current_site
from django.http import HttpRequest
BASE_URL = getattr(settings, 'REQUEST_BASE_URL', 'http://{0}'.format(get_current_site(HttpRequest()).domain)) # <---***
except Exception:
BASE_URL = getattr(settings, 'REQUEST_BASE_URL', 'http://127.0.0.1')
If I runserver from the command-line it works.
If I launch inside Visual Studio I get SERVER_NAME is not found (in request META). Any ideas?