I'm trying to achieve the following model structure:
class X(models.Model):
class Meta:
abstract = True
objects = InheritanceManager()
agroup = models.ForeignKey(A, related_name="%(class)s_set")
xfield = models.CharField()
class A(models.Model):
class Y(X):
yfield = models.CharField()
class Z(X):
zfield = models.CharField()
The first issue is, the Base X class can't be abstract it seems because I need to be able to iterate over all subclasses of X (Y,Y,Y,Z,Z) so I need access to the manager. While X is abstract, X.objects doesn't work.
Second issue is in the REST serializer. I can only reference x_set in ASerializer, as it is the only property that exists on A. And that only display the xfield in the nested list. What I would really like is y_set and z_set on the ASerializer with their respective yfield and zfield displayed.
I can achieve some of this with different configurations (iteration over children by removing abstract, or separation of children in the rest serializer by places the FK field on Y and Z directly), but never all the same time.
Thank you.