Closed youpsla closed 9 months ago
The solution I found as of now is to setup another server. Then, one Django server and one "Enaml-redering-and-cache-server". When Django receive a request, he send a request to the "Enamll" server and get the HTML (Partial or full page).
Have you tried using django's cache framework to save the page?
Or more simply some global variable outside the request handler? Something like this:
CACHE = {}
def testview(request):
cache_key = "index"
data = CACHE.get(cache_key)
if data is None:
# page is not in cache, render it and save it in the cache
print("Creating cache")
index = Index()
data = (index, index.render())
CACHE[cache_key] = data
else:
print("Using cache")
index, page = data
return HttpResponse(page)
A similar approach will work with the dataframe viewer example.
I close this ticket because I solved the issue a long time ago and forgot it. Thanks again for help.
Hello !!! I'm trying to integrate Enaml-web and Django using the CACHE system used ind dataframe example here:https://github.com/codelv/enaml-web/blob/37752a0221d1b9734d063daedbf39a3d9b9f51e3/examples/dataframe_viewer/app.py#L48
I don't achieve to persist this object between users interactions, in other works, after the answer has been sent back to the user browser.
Any idea to achieve that ?
Here is my simple view: