mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Fix : This is not a rw operation but a ro for db routers
This commit is contained in:
parent
8d32fcb928
commit
d2ee39359f
1 changed files with 3 additions and 1 deletions
|
@ -54,6 +54,8 @@ class PreferencesModel(models.Model):
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_in_cache(cls):
|
def set_in_cache(cls):
|
||||||
"""Save the preferences in a server-side cache."""
|
"""Save the preferences in a server-side cache."""
|
||||||
|
instance = cls.objects.first()
|
||||||
|
if not instance:
|
||||||
instance, _created = cls.objects.get_or_create()
|
instance, _created = cls.objects.get_or_create()
|
||||||
cache.set(cls().__class__.__name__.lower(), instance, None)
|
cache.set(cls().__class__.__name__.lower(), instance, None)
|
||||||
return instance
|
return instance
|
||||||
|
|
Loading…
Reference in a new issue