Questions tagged [multi-table-inheritance]

52 questions
1
vote
1 answer

Rails polymorphic association with multiple foreign keys and database constraints

I've been playing with Multi-Table inheritance and database constraints. I know that Rails philosophy is to handle constraints in the code and not in the database but I'd like to do both. I also know about polymorphic associations but they don't let…
1
vote
1 answer

'Can't mass-assign protected attributes' when implementing Multiple Table Inheritance with nested forms

HI I am trying to implement the MTI in my application. I have a Person Model and 2 models inheriting from it: Client and TeamMember. When creating a Team Member I want to save to to database vallues for both person (first and last name, email etc)…
1
vote
0 answers

Django 1.5 select_related defer with multi table inheritance

EDIT: I fixed a few typos below I added a zip file to a small app to demonstrate this problem here. You can download it and run python manage.py testselectrelateddefer after you syncdb and migrate. I added a couple of observations below I fix I am…
1
vote
2 answers

how to conditionally save a form using django multi table inheritance

I have the following form: class PlaceForm(forms.ModelForm): class Meta: model = Place I have the following models: class Place(models.Model): customer = models.ForeignKey(Customer) name = models.CharField(max_length=50) …
Atma
  • 29,141
  • 56
  • 198
  • 299
1
vote
1 answer

How to allow user to edit post with Django?

In my blog I decided to allow users to edit posts (I am using Django), but I am not sure what is the right implementation for my models to do that. Is a good idea to use multi-table inheritance as my code below? I also want to keep track of all the…
Pompeyo
  • 1,459
  • 3
  • 18
  • 42
1
vote
2 answers

Multiple level Inheritance Mapping with doctrine 2

I have three entities which are "Addressable" (can have an Address): Delivery Points Customers Distribution Centers Every Addressable entity also is Geolocatable (has latitude and longitude), but i have entities that are Geolocatable but not…
1
vote
1 answer

Multiple Table Inheritance, columns not accessible from sub class

UPDATE: changing table_name to self.table_name = seems to have convinced rails to use the correct table. I am, however, now getting these weird errors Mysql2::Error: Unknown column 'templates.deleted_at' in 'where clause': SELECT `objekts`.*…
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
0
votes
1 answer

Add Django model parent class to an existing "child" model for multi-table inheritance

I would like to add a new parent class to an existing model, which inherits from the same "super" parent class. Example of initial condition: from django.db import models class Ticket(PolymorphicModel): name = models.CharField(max_length=50) …
0
votes
1 answer

Elegantly spread single Django model across multiple tables?

There's plenty of document and discussion for having multiple models share fields in a parent class/table using "concrete" or "multi-table" inheritance: class Place(models.Model): ... class Restaurant(Place): ... However, I can't find much…
odigity
  • 7,568
  • 4
  • 37
  • 51
0
votes
2 answers

Extend model in Ruby on Rails for RESTful api app

As a part of a project we got an UML diagram to implement. Now I'm at the part of OOP, but I'm not sure how to implement that in Ruby. Every Task is a Chore or Homework, as I understand it must be multi table inheritance(MTI). I'm not sure how to…
0
votes
1 answer

How do you set up MTI in Rails with a polymorphic belongs_to association?

In an effort to create a Short, Self Contained, Correct (Compilable), Example, imagine that I want to do the following. I have a blog website. There are two types of posts, TextPost and LinkPost. There are also two types of users, User and Guest. I…
0
votes
0 answers

Empty QuerySet for Django Multi-Table Inheritance Subclass

I have the following models: APP 1: class User(AbstractBaseUser): # custom fields etc # NOT ABSTRACT APP 2: class SecondaryUser(User): # other custom fields When I do SecondaryUser.objects.create(...) I get an instance as…
RHSmith159
  • 1,823
  • 9
  • 16
0
votes
0 answers

Query optimisation for FK association on inherited model from the base model

I have users who create (or receive) transactions. The transaction hierarchy I have is a multi-table inheritance, with Transaction as the base model containing the common fields between all transaction types, such as User (FK), amount, etc. I have…
Maps
  • 135
  • 10
0
votes
1 answer

How should I model different document types?

I am building a Ruby On Rails API that helps manage construction documents -- there are a number of different types of documents that all have different fields, so I currently have a model for each. However, I also would like the ability to refer to…
0
votes
1 answer

Is polymorphic query of base Model in case of Multi-table inheritance in Django possible?

I.e. we have class Place(models.Model):... class Restaurant(Place):... class Cafe(Place):... I'd like to query Place somehow: q = Place.objects.all() # how? but for q[x] i'd like to have not Place class instance, but Restaurant or Cafe instead…
john.don83
  • 103
  • 1
  • 10