I Use django 3.2 I need to change DEBUG option from admin page to do that I install Django-constance
I add these in setting.py:
from constance import config
CONSTANCE_CONFIG = {
'DEBUG':(True,'Debug mode'),
}
# answer_the_question()
DEBUG=config.DEBUG
and this signal in models.py
@receiver(config_updated)
def constance_updated(sender, key, old_value, new_value, **kwargs):
print(sender, 'DEBUG', old_value, new_value)
but its not work
Did you add: 'constance' in INSTALLED_APPS at settings.py?
you also needs to ou a new value like
CONSTANCE_CONFIG = {
'DEBUG':(True, False)
}
Try that! or if you wanna describe with a string you need a use a tuple:
CONSTANCE_CONFIG = {
'DEBUG':((True, 'DEBUG MODE'), (False,'UNDEBUG MODE'))
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.