8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +00:00

Fix : This is not a rw operation but a ro for db routers

This commit is contained in:
Gabriel Detraz 2020-09-19 14:00:06 +02:00
parent 939c0e28aa
commit e6bd154116

View file

@ -54,7 +54,9 @@ 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, _created = cls.objects.get_or_create() instance = cls.objects.first()
if not instance:
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