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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:44:35+00:00 2026-05-13T06:44:35+00:00

Lets say I have three django model classes – lets call them A, B

  • 0

Lets say I have three django model classes – lets call them A, B and C. If A and B are abstract, I can do something like:

class C(A,B):
    pass

What if they aren’t abstract and I do the same? Will everything still work correctly or no? Or have I got it wrong and this should not be done with abstract models either?

I’m having some issues which I’m attributing to the fact that the answer is probably no, but I’d still prefer to make sure about this if anyone knows 🙂
The specific use case I had for this is probably better served by Generic Relations (I only recently discovered their existence), so I guess it would be understandable if the Django team made a design decision like this (I can’t see many people needing to do this). I’d just like to know for sure what the case is.

Edit 1 (after Dominic’s answer)

Interesting… The problem we’re having is a structure similar to IMDb (I think IMDb is a bit easier to understand than the topic matter we actually have, so I’ll use them as an example). On IMDb they have pages for People and pages for Movies and both People and Movies have their own message boards.

We’ve ended up connecting message boards to the People and Movies by creating a model called MessageboardOwner (with only one attribute – the id added automatically by Django), which "owns" the message board and People and Movies inherit it. The problem is that our "People" class inherits from two other classes also. The class definition is something like:

class Person(A,B,MessageboardOwner):

Initially this seemed to work out fine, but then today something rather weird happened… I was deleting a Person in the admin and the admin asked the "Are you sure?" question and was showing me what other objects it would have to delete. It was trying to delete two message boards, not one. One of these message boards should have been owned by a Movie, not a Person.

Upon looking at what exactly was in the database, I found that this Person instance was using the same MessageboardOwner instance as the Movie was. When I played around with it, what came out was that the Movie class, which inherited only after MessageboardOwner, seemed to work ok. Saving the Person, however, only created a MessageboardOwner object if one didn’t already exist (or possibly overwrote the existing one – I’m not sure). I also found that the id fields inherited from A, B and MessageboardOwner were always equal, which seemed strange to me.

  • 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-13T06:44:35+00:00Added an answer on May 13, 2026 at 6:44 am

    Yes, you can use normal Python multiple-inheritance with models. Bear in mind this warning though:

    Just as with Python’s subclassing,
    it’s possible for a Django model to
    inherit from multiple parent models.
    Keep in mind that normal Python name
    resolution rules apply. The first base
    class that a particular name (e.g.
    Meta) appears in will be the one that
    is used; for example, this means that
    if multiple parents contain a Meta
    class, only the first one is going to
    be used, and all others will be
    ignored.

    Generally, you won’t need to inherit
    from multiple parents. The main
    use-case where this is useful is for
    “mix-in” classes: adding a particular
    extra field or method to every class
    that inherits the mix-in. Try to keep
    your inheritance hierarchies as simple
    and straightforward as possible so
    that you won’t have to struggle to
    work out where a particular piece of
    information is coming from.

    From the Django docs.

    Generally, multiple inheritance is a bad idea, and there are simpler ways to do things. If you flesh out what problem you’re trying to solve a bit more clearly, we might be able to help a bit better.

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

Sidebar

Ask A Question

Stats

  • Questions 301k
  • Answers 301k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer At the ghci command prompt, you can type: :info >>… May 13, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer I'm doing something like this with the jQuery UI tabs,… May 13, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer I recommend to use Lucene.net for indexing and searching that… May 13, 2026 at 8:14 pm

Related Questions

So let's say I'm using Python 2.5's built-in default sqlite3 and I have a
There are a lot of complex forms in my project and I keep getting
I'm gonna try and simplify this as much as possible. Lets say i have
Let's say trying to use django.views.generic.create_update.create_object to allow the user to a blog entry
I was wondering if the django admin page can be used for external users.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.