diff options
-rw-r--r-- | ishtar_common/models_common.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 6fb0d2fbc..83245f0ff 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -21,24 +21,23 @@ import time from django import forms from django.apps import apps from django.conf import settings -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey -from django.db import migrations as db_migrations from django.contrib.gis.db import models from django.contrib.gis.geos import GEOSGeometry, Point from django.contrib.gis.gdal.error import GDALException from django.contrib.postgres.fields import JSONField from django.contrib.postgres.search import SearchVectorField, SearchVector from django.contrib.sites.models import Site -from django.core.cache import cache +from django.core.cache import cache as django_cache from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.core.files import File from django.core.serializers import serialize from django.urls import reverse, NoReverseMatch from django.core.validators import validate_slug from django.db import connection, transaction, OperationalError, IntegrityError -from django.db.models import Q, Count, Max, fields +from django.db.models import Q, Count, Max from django.db.models.signals import post_save, post_delete, m2m_changed from django.template import loader from django.template.defaultfilters import slugify @@ -50,7 +49,6 @@ from ishtar_common.utils import ( get_image_path, get_columns_from_class, human_date, - reverse_list_coordinates, ) from simple_history.models import HistoricalRecords as BaseHistoricalRecords from simple_history.signals import ( @@ -105,7 +103,7 @@ class CachedGen(object): current_keys = [] if keys not in current_keys: current_keys.append(keys) - cache.set(cache_ckey, current_keys, settings.CACHE_TIMEOUT) + django_cache.set(cache_ckey, current_keys, settings.CACHE_TIMEOUT) class Cached(CachedGen): @@ -144,7 +142,7 @@ class Cached(CachedGen): current_keys = [] if keys not in current_keys: current_keys.append(keys) - cache.set(cache_ckey, current_keys, settings.CACHE_TIMEOUT) + django_cache.set(cache_ckey, current_keys, settings.CACHE_TIMEOUT) @classmethod def get_cache(cls, slug, force=False): @@ -154,10 +152,10 @@ class Cached(CachedGen): try: k = {cls.slug_field: slug} obj = cls.objects.get(**k) - cache.set(cache_key, obj, settings.CACHE_TIMEOUT) + django_cache.set(cache_key, obj, settings.CACHE_TIMEOUT) return obj except cls.DoesNotExist: - cache.set(cache_key, None, settings.CACHE_TIMEOUT) + django_cache.set(cache_key, None, settings.CACHE_TIMEOUT) return None @@ -340,7 +338,7 @@ class GeneralType(Cached, models.Model): help_text = help_text + help_items else: help_text = "" - cache.set(cache_key, help_text, settings.CACHE_TIMEOUT) + django_cache.set(cache_key, help_text, settings.CACHE_TIMEOUT) return mark_safe(help_text) @classmethod @@ -438,7 +436,7 @@ class GeneralType(Cached, models.Model): get_full_hierarchy=get_full_hierarchy, ) ] - cache.set(cache_key, vals, settings.CACHE_TIMEOUT) + django_cache.set(cache_key, vals, settings.CACHE_TIMEOUT) return vals if not cache_key: @@ -449,7 +447,7 @@ class GeneralType(Cached, models.Model): base_dct, instances, exclude=exclude, default=default ) ] - cache.set(cache_key, vals, settings.CACHE_TIMEOUT) + django_cache.set(cache_key, vals, settings.CACHE_TIMEOUT) return vals @classmethod @@ -1202,7 +1200,7 @@ class JsonData(models.Model, CachedGen): if not multi: c = [("", "")] c += [(v, v) for v in sorted(list(choices)) if v] - cache.set(cache_key, c, settings.CACHE_SMALLTIMEOUT) + django_cache.set(cache_key, c, settings.CACHE_SMALLTIMEOUT) return c |