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 8056407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:41:35+00:00 2026-06-05T08:41:35+00:00

I have an app with a similar structure as this snippet class Blog(models.Model): name

  • 0

I have an app with a similar structure as this snippet

class Blog(models.Model):
    name = models.CharField(max_length=25)

class Category(models.Model):
    name = models.CharField(max_length=25)
    blog = models.ForeignKey(Blog)

class Entry(models.Model):
    title = models.CharField(max_length=25)
    category = models.ForeignKey(Category)

What is the most generic way, that i will be able to use in other apps to fetch all blogs with their category and entries?

I thought about creating a manager for the Blog model, that can fetch all the Categories for that blog, but it’s hardcoding the model names

 class BlogManager(models.Manager):
     def categories(self):
         return Category.objects.filter(blog=self)

Any suggestions?

  • 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-06-05T08:41:36+00:00Added an answer on June 5, 2026 at 8:41 am

    What you want is a Select Related. It returns a QuerySet that will automatically “follow” foreign-key relationships, selecting that additional related-object data when it executes its query. Your query for Blogs would look something like:

    Blog.objects.select_related().filter( something )
    

    or

    Blog.objects.select_related().get( something )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several small classes that are in a single file in /app/models, similar
I'm currently working on an app with this structure: I have a view controller
I have an App using core data with 3 entities with very similar attributes.
I have a URL in a Django based web app that looks similar to
I have a layout similar to the ICS Gmail app for tablets ( ListFragment
I have app in which I'm downloading image from web to iphone app. This
My question is similar this one here: ResultsController to another ResultsController A typical app
I am creating an iPhone app which I would like to have a similar
I have something that looks like the following document structure: public class Document {
I have an Invoice model in a Rails app. The Invoice has_many Products and

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.