Questions.objects.all().order_by('?')[:5]
ie get all the rows from the Questions table, in a random order, then
show me the first five.
https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-
querysets
-- Clive
On 16 Nov 2022, at 01:14, Lakshyaraj Dash wrote:
> Hello everyone,
> I'm on my way to create a quiz app. I want that a loggedin user
> should get 5 questions randomly when he/she is visiting everytime.
> Eg:
> On first visit
> Q1. Who's the CEO of Facebook ?
>
> On second visit
> Q2. Who's the CEO of Google ?
>
> Thanks and regards
> Lakshyaraj Dash
>
>
> --
> 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 view this discussion on the web visit https://groups.google.com/
> d/msgid/django-users/CAF7qQgAAJinHYUKhY_M-
> Z0Y1ecrcHcWTyNHuHkSLdyV7QsFSqw%40mail.gmail.com.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/A99E62B4-627D-459F-B5A9-9927AF6AC9BB%40indx.co.uk.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment