Have a nice day everyone. As I mentioned in the title, I would like to join several models and identify one of them with one global identifier, so the identifier will determine which model, and I would get access to all my fields.
I am currently struggling with multiple table inheritance, and I have a problem. I would like to have one parent model and several child models that inherit some of the parent fields.
class Parent(models.Model):
pass
class Child1(Parent):
fieldX = models.CharField()
class Child2(Parent):
fieldY = models.CharField()
However, I would like to access the childs parent model using the primary key. So that...
Parent.objects.all()
should return Child1 and Child2 objects with their fields (fieldX, fieldY).
(Assume that the parent record with pk = 1 is a Child1 model)
child = Parent.objects.get(pk=1)
child.fieldX
django AttributeError: 'Parent' 'fieldX'
- - . Django? , ? , contenttype GUID, UUID, , , . !