mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
better DB handling
This commit is contained in:
parent
46fe20dcd7
commit
d1c409b1ac
2 changed files with 4 additions and 4 deletions
|
|
@ -76,11 +76,11 @@ class DatabaseBackend(Backend):
|
|||
else:
|
||||
value = None
|
||||
if value is None:
|
||||
try:
|
||||
value = self._model._default_manager.get(key=key).value
|
||||
except (OperationalError, ProgrammingError, self._model.DoesNotExist):
|
||||
match = self._model._default_manager.filter(key=key)
|
||||
if len(match) == 0:
|
||||
pass
|
||||
else:
|
||||
value = match.first().value
|
||||
if self._cache:
|
||||
self._cache.add(key, value)
|
||||
return value
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestDatabase(StorageTestsMixin, TestCase):
|
|||
with self.assertNumQueries(5):
|
||||
self.config.INT_VALUE
|
||||
|
||||
# Read again
|
||||
# Read
|
||||
with self.assertNumQueries(1):
|
||||
self.config.INT_VALUE
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue