Thanks ! It works perfectly !
Le vendredi 25 janvier 2019 17:07:05 UTC+1, C. Kirby a écrit :
-- Le vendredi 25 janvier 2019 17:07:05 UTC+1, C. Kirby a écrit :
You can use islice from itertools in this wayislice('ABCDEFG', 0, None, 2) --> A C E G
In your case you would replace
chart = temp_db.objects.filter(date__g
te =beg_range)
with
chart = [x for x in islice(temp_db.objects.filter(
date__ gte=beg_range), 0, None, 2)]
That will give you every other instance from your query set starting with the first
On Friday, January 25, 2019 at 9:02:33 AM UTC-5, Stéphane Manguette wrote:Hello;I've a DBB with a lot of values which are recorded every 2 minutes (this cannot be changed).I'm trying to get all values recorded over the last 24h
def dashboard(request):version = version_globalend_range = datetime.now()beg_range = end_range - timedelta(days=1)chart = temp_db.objects.filter(date__gte=beg_range) last_entry = chart.latest('date')return render(request, 'index.html', locals())
The following code works perfectly. The goal is to populate a Chart.js in index.html. Unfortunately, there is a lot to transmit making it long to charge. Since my chart is not mainly meant to show trends; I could skip one data over two. Is there a function do do so?Thanks a lot,Stéphane
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cc8de795-21bd-4b75-b8ff-b676e528c3c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment