Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cache after instance save #92

Open
matt-dalton opened this issue Jan 27, 2021 · 0 comments
Open

Update cache after instance save #92

matt-dalton opened this issue Jan 27, 2021 · 0 comments
Labels

Comments

@matt-dalton
Copy link

Maybe I'm missing something obvious, but is there a way to clear the cache after saving the instance directly, instead of via the form?

We have one singleton that's updated automatically via a worker task, so doesn't go through the form. If I run this:

sgtn = MySingleton.get_solo()
sgtn.name = 'New Value'
sgtn.save()

and then I query the result using MySingleton.get_solo().name I get the previous value.

I tried overriding the save method like this:

def save(self, *args, **kwargs):
        self.clear_cache()
        super().save(*args, **kwargs)  

But that didn't work either. Is there a way of configuring this? Seems like quite a reasonable use case if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants