trueno
January 17, 2019, 8:25am
1
Hi. I am having an issue with context in templates.
I have website generator with function get_context
def get_context(self, context):
context.no_cache = True
context = {
"id": self.id,
"text": self.text,
"assigned_to": self.assigned_to,
}
It was working normally, but in some point context stoped to update. Even if I deleting get_context function my template still the same with previous values.
Unfortunately i didn’t find docs for this problem.
What I already tried:
context.no_cache = True
bench --site all clear-website-cache
bench --site mysite clear-website-cache
bench clear-website-cache
bench --site mysite clear-cache
bench clear-cache
No luck. Any suggestions?
Frappe version v12.x.x-develop () (develop)
1 Like
grh
February 16, 2021, 9:51am
2
Did you find any solution for this? I am facing the same issue.
Hey, did you find its solution? Same problem here (Oct, 2021)
ritwik
January 17, 2022, 5:51pm
4
can you once try putting no_cache = 1
in the global scope where your get_context
function lives?
I’ve seen that across frappe codebase so i think it might work (?)
1 Like
Is there anyone who found solution for this issue?
sione
March 16, 2022, 7:23am
6
Try this
#bench restart
or
#sudo supervisorctl restart all
either will clear all cache
Thank you for the reply. I am using ERPNext in production. after running this command => sudo supervisorctl restart all it is working fine now
fyi i tried to clear all the cache but it didn’t solve the problem
sione
March 16, 2022, 8:21am
8
Glad to help, with the command there are two version
sudo service supervisord restart
sudo supervisorctl restart all
Try either one of those two
treeem
January 3, 2024, 4:09am
9
ritwik:
no_cache
For me , this solved my issue.
example:
def get_context(context):
param = frappe.request.environ.get('QUERY_STRING')
asset_code = param.split("=")[1].replace("%20"," ")
query = f""" .... """
asset_table = frappe.db.sql(query, as_dict=True)
context.no_cache = 1 # <--- this line
context.asset_table = asset_table
return context
1 Like