Skip to content Skip to sidebar Skip to footer

Querying For Followers In News-feed-based Data Model In Django

I have this following (simplified) model in Django which is very similar to the Pinterest data model: class UserProfile(models.Model): user = models.OneToOneField(User) class

Solution 1:

The first would be something like this I think:

User.objects.filter(collection_owner__owner='the user')

The latter should be something like this:

Item.objects.filter(collections__followers='the user').distinct()

You should be aware however that these type of queries do not scale to large amounts of data. Doing that will require quite a bit of hacking...

Post a Comment for "Querying For Followers In News-feed-based Data Model In Django"