Hello everyone and thank you so much for bringing to life this forum!
I was wondering what’s the recommended approach for handling virtual hosts in Django. At the stage I’m in this project, the site framework is a bit overkill. Here’s what I did instead:
def check_domain(request): if not request.get_host() == SITE: raise PermissionDenied
and then in each view:
def index(request): check_domain(request) # do stuff
This appoach prevents the user from reaching paths that are not associated with the correct host header. I know it’s a dirty hack, I’m thinking of a custom decorator or a mixin, but I was wondering if there is already some best practice I’m missing.