Skip to content

SERVER_NAME not found in HttpRequest() in VS2019 #244

@billyquith

Description

@billyquith

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions