Skip to content

Instantly share code, notes, and snippets.

@minism
Created February 13, 2012 22:45
Show Gist options
  • Save minism/1821196 to your computer and use it in GitHub Desktop.
Save minism/1821196 to your computer and use it in GitHub Desktop.
maintenance mode middleware
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