Skip to content

Commit

Permalink
Better special case for promises
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebryant committed Nov 11, 2015
1 parent 835639d commit 4cec90a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion django_autoconfig/autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4cec90a

Please sign in to comment.