Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3432482
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:27:17+00:00 2026-05-18T07:27:17+00:00

The site I’m building allows users to create posts and has a Twitter-like concept

  • 0

The site I’m building allows users to create “posts” and has a Twitter-like concept of followed users. For a given user, I’d like to show all of the posts from the users that they follow.

Here are my simplified models:

class User
    # a standard django.contrib.auth user model

class UserProfile(models.Model):
    # my AUTH_PROFILE_MODULE for django-profiles
    user = models.ForeignKey(User, unique=True)
    following = models.ManyToManyField('self', symmetrical=False, related_name="followed_by")

class Posts(models.Model):
    user = models.ForeignKey(User)
    post = models.TextField()

Question: How do you create a queryset of all Post objects from the Users that a given User is following?

I think I’ve made it more complicated by creating the “follow” relationship on UserProfile, which is not the model with the ForeignKey relationship with Posts.

UPDATE! Here’s the answer:

Posts.objects.filter(user__userprofile__in=UserProfile.objects.get(user=your_user_object).following.all())
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:27:17+00:00Added an answer on May 18, 2026 at 7:27 am
    Posts.objects.filter(user__in=UserProfile.objects.get(user=your_user_object).following)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site has quite a deep navigation structure and quite often it looks like
Site 1 has dll's for x amount of object and data calls. Can Site
My site has a drop-down menu built in CSS and JavaScript that drops down
A site I'm working on has Flash headers (using swfobject to embed them). Now
Our site has multiple wizards where various data is collected over several pages, and
What site(s) do you recommend for looking at complimentary colors for site design? It
A site I am working on that is built using PHP is sometimes showing
This site is pretty good but I'm wondering what other resources are out there.
The site I'm working on is using a Databound asp:Menu control. When sending 1
the site addres: http://www.ynet.co.il/YediothPortal/Ext/TalkBack/CdaTalkBack/1,2497,L-3650194-0-68-544-0--,00.html fill the form with rubbish. Hit 'Send' the form post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.