'How can I show randomly different data for each user in Django?

I have a tag system in Django with the following model;

class Data(models.Model):
    new = models.ChardField()
    is_tagged = models.BooleanField(default=False)

class Tag(models.Model):
    data = models.ForeignKey(Data,on_delete=models.CASCADE,related_name="data")
    status = models.CharField(verbose_name="New Status",max_length=10,null=True)

The tag status holds "positive", "negative", and "pass".

There is a page called "new tags" and around 100 users will enter the page at the same time.

There are 10000 data and users will enter the page and just click "positive", "negative", and "pass".

I want to show different data for each user.

EDIT

New1: id = 1,is_tagged=False

New2: id = 2,is_tagged=False
User 1: Display New1

User 2: Display New1
User 1: Tag: "Positive" and id = 1, is_tagged will be "True"

Because both user open the windows at the same time, after 1 second,

User 2: Tag: "Pass" and id = 1 , is_tagged will be "False"

I want to prevent this situation. It supposed to be;

User 1: Display New1
User 2: Display New2

So each user must display different News Data to tag.

Let's say a user tagged the new as "positive". If I will send the new with random() it can be the same at another user unluckily. And the user can tag as "pass". This status will make "Data" "is_tagged" False. But other users tagged "positive" before.

How can I prevent users see the same data at the same time?



Solution 1:[1]

If you need to get a random object, you could do something like:

import random 

all_object_ids = Data.objects.all().values_list('id', flat=True) # gets list of all object ids

random_id = random.choice(all_object_ids) # picks a random id from list

random_tag = Data.objects.get(id=random_id)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Milo Persic