Python django.http.request.validate_host() Examples

The following are 1 code examples of django.http.request.validate_host(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.http.request , or try the search function .
Example #1
Source File: views.py    From django-cc with MIT License 5 votes vote down vote up
def cc_validate_host(func):
    def validate(request):
        domain, port = split_domain_port(request.META['HTTP_HOST'])
        if not validate_host(domain, settings.CC_ALLOWED_HOSTS):
            return HttpResponseForbidden('forbiden')

        return func(request)

    return validate