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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:02:41+00:00 2026-05-31T09:02:41+00:00

Possible Duplicate: Django Model Inheritance query a central table Following along the officail docs

  • 0

Possible Duplicate:
Django Model Inheritance query a central table

Following along the officail docs found here
https://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance

I see that I can query Place which is a Super of Restaurant via

p = Place.objects.filter(name="Bob's Cafe")

So at that point is there a way to check and see if the objects returned are also of type sub class Restaurant and if so access their sub class fields?

At the moment all I can tell is that all the objects returned are of Place class and their sub class properties and methods are not available since the object is not being cast as its sub class.

If this methodology is not possible then what is the best practice went trying to abstract a super class and minimize the overhead of queries when trying to get a list containing all the subclass models? I understand in theory I could do do a query of each sub class then combined the list together but then I would have to do more if I wanted to order that list by say a date.

  • 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-31T09:02:42+00:00Added an answer on May 31, 2026 at 9:02 am

    So at that point is there a way to check and see if the objects returned are also of type sub class Restaurant and if so access their sub class fields?

    If you’ve queried the Place model, the objects returned are Place instances that have no knowledge of any MTI-associated subclasses. You need to provide a field on the superclass to link downward to the subclass. See Making a multi-table inheritance design generic in Django

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

Sidebar

Related Questions

Possible Duplicate: Django dynamic model fields Good Morning guys! Scenario is the following. For
Possible Duplicate: Override django-admin edit form field values for encrypted data The inline model
Possible Duplicate: Django - Iterate over model instance field names and values in template
Possible Duplicate: Verbose name for admin model Class in django I had a model
Possible Duplicate: Django QuerySet ordering by expression If I had a model with 3
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: django - ordering queryset by a calculated field How can i use
Possible Duplicate: Django data migration when changing a field to ManyToMany how I can
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: How to compare datetime in Django? I need to compare 2 dates

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.