If you just want a random user, you could just use random.choice(). You can
use it in shell, in a function or wherever you want.

Example:

import random
users = User.objects.all() #a list of all users
random_user = random.choice(users) #a random user

On Mon, Apr 19, 2021 at 20:45 Mustafa Burhani <[email protected]>
wrote:

> I want to Choose random user from databse is possible with django shell or
> need to create model ? for random function ?
>
>
> Thanks !
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/055d5a55-ad28-4a97-b1ec-1d16369cc2a2n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/055d5a55-ad28-4a97-b1ec-1d16369cc2a2n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
KeLLs

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADYqDX1275VyPJcTfnX7%2B%3DtbmMSaFTYxph0m0t%2B-PH3bTLK9Ow%40mail.gmail.com.

Reply via email to