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

  • SEARCH
  • Home
  • 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 887635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:15:37+00:00 2026-05-15T13:15:37+00:00

I want to make a ‘timeline’ containing all mini blog posts from a user,

  • 0

I want to make a ‘timeline’ containing all mini blog posts from a user, and all the user he is following.
I want all these posts to be ordered by date., but how can I ‘join’ the posts, because the ‘following’ relation is in another table, so I have to make some kind of a join between the two tables, for taking the data.

For now, in my ‘timeline’, there appears only the blog posts of the owner of the blog, and I user a query like:

     blog = New.objects.filter(created_by = request.user) 

but I want to join there posts with the posts of the persons he is following, meaning:

    following = Relations.objects.filter(initiated_by = request.user)

where Relations is the ‘Follow relation’ table.

How can I do it?

My models:

class New(models.Model):
post = models.CharField(max_length=120)
date = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(User, blank=True) 
objects = NewManager()   


class Relations(models.Model):
initiated_by = models.ForeignKey(User, editable=False, related_name = 'initiator')
date_initiated = models.DateTimeField(auto_now=True, editable = False)
follow = models.ForeignKey(User, editable = False, related_name = "follow") 
date_follow = models.DateTimeField(auto_now=True, editable = False)
  • 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-15T13:15:37+00:00Added an answer on May 15, 2026 at 1:15 pm

    Maybe something like (using Q objects):

    blogs = New.objects.filter(Q(created_by = request.user) | Q(relations_set__initiated_by = request.user))
    

    This assumes that you have a foreign key from Relations to New. See the documentation about following relationships backward.

    If your Relations model doesn’t have a foreign key to New but a foreign key to the users table, say following = models.ForeignKey(User), then you can maybe do something like

    blogs = New.objects.filter(Q(created_by = request.user) | Q(created_by__follow__initiated_by = request.user))
    

    Now, your foreign key from the Relations model to the user model should have related_name = 'follow'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want make query select all names from table 'a' where from table 'b'
I want make a bash script which returns the position of an element from
I want make interactive application where user launches it and can do various task
Let's say I want make some of my sources publicly available via my blog
I want make sql query which will insert values from one table to another
i want make a news site gets its content from other news sites, open
Want make a mind map like the following: Image link is not available anymore.
I want make a page (HTML + CSS) that fits all the space left
I am newer for php. I want make php page cache, query data from
From mysql query, I want make 5 results as a group wrap into a

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.