Last active
November 21, 2020 03:04
-
-
Save VasiliyBologov/50d09d7cac8ae84e341602c5ac9cf2a7 to your computer and use it in GitHub Desktop.
maintenance mod decorator for django
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
MAINTENANCE_MOD = True | |
def maintenance(the_func): | |
""" | |
Make action for maintenance mod | |
""" | |
def _decorated(*args, **kwargs): | |
if MAINTENANCE_MOD: | |
print('MAINTENANCE MOD ON') | |
return render(*args, 'maintenance.html', {}) | |
else: | |
return the_func(*args, **kwargs) | |
return _decorated | |
@maintenance | |
def main(request): | |
return render(request, 'main.html', {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment