mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Clear cache on save if active
This commit is contained in:
14
ram/ram/apps.py
Normal file
14
ram/ram/apps.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from django.conf import settings
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class RamConfig(AppConfig):
|
||||
name = "ram"
|
||||
|
||||
def ready(self):
|
||||
cache_middleware = set([
|
||||
"django.middleware.cache.UpdateCacheMiddleware",
|
||||
"django.middleware.cache.FetchFromCacheMiddleware",
|
||||
])
|
||||
if cache_middleware.issubset(settings.MIDDLEWARE):
|
||||
from ram.signals import clear_cache # noqa: F401
|
8
ram/ram/signals.py
Normal file
8
ram/ram/signals.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.core.cache import cache
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
@receiver(post_save)
|
||||
def clear_cache(sender, **kwargs):
|
||||
cache.clear()
|
@@ -28,6 +28,7 @@ class RollingClass(admin.ModelAdmin):
|
||||
"company__name",
|
||||
"type__type",
|
||||
)
|
||||
save_as = True
|
||||
|
||||
|
||||
class RollingStockDocInline(admin.TabularInline):
|
||||
|
Reference in New Issue
Block a user