subdomains.middleware

class subdomains.middleware.SubdomainMiddleware(get_response=None)

A middleware class that adds a subdomain attribute to the current request.

get_domain_for_request(request)

Returns the domain that will be used to identify the subdomain part for this request.

process_request(request)

Adds a subdomain attribute to the request parameter.

class subdomains.middleware.SubdomainURLRoutingMiddleware(get_response=None)

A middleware class that allows for subdomain-based URL routing.

process_request(request)

Sets the current request’s urlconf attribute to the urlconf associated with the subdomain, if it is listed in settings.SUBDOMAIN_URLCONFS.

process_response(request, response)

Forces the HTTP Vary header onto requests to avoid having responses cached across subdomains.