Skip to content

Instantly share code, notes, and snippets.

@pbdeuchler
Created November 13, 2012 16:35
Show Gist options
  • Save pbdeuchler/4066816 to your computer and use it in GitHub Desktop.
Save pbdeuchler/4066816 to your computer and use it in GitHub Desktop.
Read Only Site Flag for Django (Request Processor)
def read_only_processor(request):
if read_only_flag():
if request.method in ['GET', 'HEAD']:
return {
'read_only': True,
'error_message': 'Sorry, this site is read only right now!"
}
else:
#return a "Read only" response
else:
return {'read_only': False, 'error_message': ''}
@pbdeuchler
Copy link
Author

Function returns a dictionary to be passed to the template processor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment