Saturday, 8 April 2023

How to parse and show info in template with requests_cache

I have several general questions about requests_cache and how is it working and how can i use that

How can i get json from 3rd party and parse that in my template? I have some information from api that i dont need to write in model in db and i want just to parse that but need just to show that in parsed info in template

views.py

def customer_view(request):

    session = requests_cache.CachedSession('project_budget_cache')
    session.get('http://someurl.com/api')

    return render(request, 'customer/customer_home.html', {'context': session})

I can get request with that but i actually dont know how to show my json in template cant help there

Another question: How can i synch request every 5 min?

Last question: How can i avoide problems with 3rd party api? Like if api is closed or they have problems and i cant get json how can i use previous request that was working? I mean if they have problems and cant accept requests rn i need to use request that was made 5 mins ago



from How to parse and show info in template with requests_cache

No comments:

Post a Comment