From 1b9458c74b0f657147a32c0e65b13662f6839043 Mon Sep 17 00:00:00 2001 From: Francesc Arpi Date: Tue, 1 Mar 2016 17:37:35 +0100 Subject: [PATCH] Added CONSTANCE_IGNORE_ADMIN_VERSION_CHECK settings option to ignore the version protection. When you use django-constance on a cloud platform, with several machines, giving you problems by keeping the machine does not have to be the same which has served constant form. --- constance/admin.py | 4 ++++ constance/settings.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/constance/admin.py b/constance/admin.py index ca9c9c4..3b8f9fe 100644 --- a/constance/admin.py +++ b/constance/admin.py @@ -103,6 +103,10 @@ class ConstanceForm(forms.Form): def clean_version(self): value = self.cleaned_data['version'] + + if settings.IGNORE_ADMIN_VERSION_CHECK: + return value + if value != self.initial['version']: raise forms.ValidationError(_('The settings have been modified ' 'by someone else. Please reload the ' diff --git a/constance/settings.py b/constance/settings.py index fd5edd4..85cc373 100644 --- a/constance/settings.py +++ b/constance/settings.py @@ -24,3 +24,7 @@ REDIS_CONNECTION_CLASS = getattr(settings, 'CONSTANCE_REDIS_CONNECTION_CLASS', REDIS_CONNECTION = getattr(settings, 'CONSTANCE_REDIS_CONNECTION', {}) SUPERUSER_ONLY = getattr(settings, 'CONSTANCE_SUPERUSER_ONLY', True) + +IGNORE_ADMIN_VERSION_CHECK = getattr(settings, + 'CONSTANCE_IGNORE_ADMIN_VERSION_CHECK', + False)