Created
February 13, 2012 22:45
-
-
Save minism/1821196 to your computer and use it in GitHub Desktop.
maintenance mode middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import http | |
from mainsite import settings | |
class MaintenanceMiddleware(object): | |
"""Serve a temporary redirect to a maintenance url in maintenance mode""" | |
def process_request(self, request): | |
if getattr(settings, 'MAINTENANCE_MODE', False) == True and hasattr(settings, 'MAINTENANCE_URL'): | |
return http.HttpResponseRedirect(settings.MAINTENANCE_URL) | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment