Fix holding config variable in database through proxy objects

A config variable may not necessarily be None when not configured. Can be stored in the database with the help of proxy objects, which can  return the None value when accessed.
For example, to integrate with jazzband/django-constance.
This commit is contained in:
Bodnar Bogdan 2017-08-15 17:52:12 +02:00 committed by GitHub
parent e1d060398c
commit add3baff74

View file

@ -21,8 +21,8 @@ def get_required_setting(setting, value_re, invalid_msg):
value = getattr(settings, setting)
except AttributeError:
raise AnalyticalException("%s setting: not found" % setting)
if value is None:
raise AnalyticalException("%s setting is set to None" % setting)
if not value:
raise AnalyticalException("%s setting is not set" % setting)
value = str(value)
if not value_re.search(value):
raise AnalyticalException("%s setting: %s: '%s'"