From 4cec90adc5ddf9941cb7649e9053eeb69396e6d3 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Wed, 11 Nov 2015 19:08:36 +0000 Subject: [PATCH] Better special case for promises --- django_autoconfig/autoconfig.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/django_autoconfig/autoconfig.py b/django_autoconfig/autoconfig.py index 05525a0..640fb6e 100644 --- a/django_autoconfig/autoconfig.py +++ b/django_autoconfig/autoconfig.py @@ -5,6 +5,7 @@ from django.core.exceptions import ImproperlyConfigured from django.conf import global_settings from django.conf.urls import include, patterns, url +from django.utils.functional import Promise from django.utils.module_loading import module_has_submodule import importlib import operator @@ -129,12 +130,18 @@ def merge_dictionaries(current, new, only_defaults=False, template_special_case= current[key] = list(current_value) + [element] LOGGER.debug("Added %r to %r.", element, key) changes += 1 - else: + elif isinstance(current_value, Promise): # If we don't know what to do with it, replace it. if current_value is not value: current[key] = value LOGGER.debug("Set %r to %r.", key, current[key]) changes += 1 + else: + # If we don't know what to do with it, replace it. + if current_value != value: + current[key] = value + LOGGER.debug("Set %r to %r.", key, current[key]) + changes += 1 return changes def configure_settings(settings, environment_settings=True):