Questions tagged [multi-table-inheritance]
52 questions
57
votes
5 answers
Should I avoid multi-table (concrete) inheritance in Django by any means?
Many experienced developers recommend against using Django multi-table inheritance because of its poor performance:
Django gotcha: concrete inheritance by Jacob Kaplan-Moss, a core contributor of Django.
In nearly every case, abstract inheritance…

utapyngo
- 6,946
- 3
- 44
- 65
37
votes
2 answers
Django 1.9: Field clashes with the field of non-existing field in parent model
I have some simple models, Profile, Certifier and Designer, the two latter inheriting from Profile (multi table inheritance). In Designer there’s a foreign key to Certifier.
class Profile(models.Model):
TYPES = (
('admin',…

Jens-Erik Weber
- 478
- 1
- 4
- 11
13
votes
2 answers
has_one through and polymorphic associations over multi-table inheritance
In the project i'm currently developing under rails 4.0.0beta1, i had the need for a user based authentication in which each user could be linked to an entity. I'm kinda new to rails and had some troubles doing so.
The model is as following:
class…

Crystark
- 3,693
- 5
- 40
- 61
6
votes
4 answers
Django post_save signal on parent class with multi-table inheritance
In Django, if you have models that use multi-table inheritance, and you define a receiver for a post_save signal on the parent class, does that receiver function get called when an instance of the child class is saved?
Borrowing an example from…

Lorin Hochstein
- 57,372
- 31
- 105
- 141
5
votes
2 answers
Add Django model parent class to existing an existing model for multi-table inheritance
The Django Docs uses this example to demonstrate multi-table inheritance:
from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
class Restaurant(Place):
…

Ryan Allen
- 5,414
- 4
- 26
- 33
5
votes
1 answer
Django adding `choices` to an inherited model field
Using multi-table inheritance, I have two models:
class Bird(models.Model):
color = models.CharField()
class Bluebird(Bird):
...
Using these models, I can do this:
birds = Bird.objects.all()
for bird in birds:
print bird.color
This is…

user3934630
- 281
- 2
- 9
5
votes
3 answers
id of object is none after save in django
I'm looping through a list of objects and saving. I need the newly generated id or pointer id right after the save but it is None.
Here is my code:
for category in category_list:
saved_category = category.save()
print…

Atma
- 29,141
- 56
- 198
- 299
4
votes
1 answer
Django Multi-Table Inheritance "ptr" On Delete DO_NOTHING
Is there a way to apply FK options (db_constraint, on_delete, etc.) to the "_ptr" column automatically created when using multi-table inheritence? I want to stop Django from emulating on delete cascade behavior and have the database perform that…

Charlie
- 151
- 1
- 1
- 5
4
votes
2 answers
Nested forms with multiple table inheritance
How do I build a nested form for objects using multiple table inheritance in rails? I am trying to make a nested form to create an object using a model with a has_many relationship to another set of models that feature multi-table inheritance. I am…

sutee
- 12,568
- 13
- 49
- 61
3
votes
2 answers
Best approach to implement inheritance in a data warehouse based on a postgres database
I am developing a multi-step data pipeline that should optimize the following process:
1) Extract data from a NoSQL database (MongoDB).
2) Transform and load the data into a relational (PostgreSQL) database.
3) Build a data warehouse using the…

GRoutar
- 1,311
- 1
- 15
- 38
3
votes
0 answers
Django select_related on multitable inheritance
I'm tring to use select_related on multi-table inheritance lookup.
My code has some drawbacks and wonder if there are better solution
class Parent(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
class Child(models.Model):
…

eugene
- 39,839
- 68
- 255
- 489
3
votes
2 answers
Querying multiple Django models
I'm looking for some advice on how to execute a query against multiple objects and then use them together in a detail view for their related object. Here is what I'm working with right now:
-- app/models.py --
class Material(models.Model):
…

Chris Shelton
- 6,108
- 4
- 15
- 13
3
votes
0 answers
Django - Multi-table inheritance - reverse relation to SubClass
I would appreciate your help with following problem.
Lets use models from Django documentation to illustrate my situation.
models.py
from django.db import models
class Place(models.Model):
owner = DjangoModels.ForeignKey('Owner',…

user2852277
- 51
- 4
2
votes
0 answers
Django - Multi Table Inheritance with django admin
I am trying to learn django by creating a blog on my own, and I've tried some real simple steps before, but now I want to make something slightly more complex. Currently, I am thinking of dividing the blogs' 'Stories' into 'Blocks'. My idea is to…

Mehran
- 1,264
- 10
- 27
2
votes
1 answer
Multi Table Inheritance Queries
Setting:
A is a model
With attributes [name, email, actable_id, actable_type]
B and C are sub types of A (as an MTI relation)
Using this gem to simulate MTI
A.rb
class A < ActiveRecord::Base
actable
...
end
B.rb
class B < A
acts_as :A
…

cmcdaniels
- 145
- 1
- 3
- 13