A
A
Andreychik322017-03-23 18:53:58
Django
Andreychik32, 2017-03-23 18:53:58

How to load elements in Django?

Hello.
How to make elements load dynamically in Django? For example, I have code in my view that sorts out a lot of information from the database. As a result, the page takes a long time to load. I tried to solve the problem with the @cache_page() decorator, but then I realized that it was inefficient.
How to execute my code separately from page loading? So that the page loads quickly, and the code loads later.
Example: For example, I have several CS:GO servers, from each of the servers it is necessary to collect information about how many players are currently playing. But these queries take a long time to complete. In the HTML page itself, it looks like this (a circle that will fill up with the appearance of people on the server):
49838490910148fab6e5e885b4c9fca3.png
It needs to be displayed over time, because. it takes a long time to load.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2017-03-23
@sim3x

www.celeryproject.org
cron is ok if the tasks are periodic and do not depend on the user

D
devalone, 2017-03-23
@devalone

If you need to periodically poll the server, then use celery, here it is perfectly described how to connect it to django docs.celeryproject.org/en/latest/django/first-step... If you need to load content dynamically, then ajax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question