Using https://github.com/jpwatts/django-positions,
I have a few models that inherit from a parent one, for example:
class ContentItem(models.Model):
class Meta:
ordering = ['position']
content_group = models.ForeignKey(ContentGroup)
position = PositionField(collection='content_group', parent_link='contentitem_ptr')
class Text(ContentItem):
title = models.CharField(max_length=500, unique=False, null=True, blank=True)
Using https://github.com/jpwatts/django-positions,
I have a few models that inherit from a parent one, for example:
class ContentItem(models.Model):
class Meta:
ordering = ['position']
content_group = models.ForeignKey(ContentGroup)
position = PositionField(collection='content_group', parent_link='contentitem_ptr')
class Text(ContentItem):
title = models.CharField(max_length=500, unique=False, null=True, blank=True)
I understand I need to use the parent_link argument (here's the documentation). But I get this error when I use it:
websites.Text: (models.E015) 'ordering' refers to the non-existent field 'position'.
When using the parent_link
argument it's as if the position
field has been deleted out of the model completely. I've tried various field names such as contentitem_ptr_id
(the actual name of the linking field), but no luck. Anything identifiable I'm doing wrong here?
Django will automatically create a OneToOneField linking your child class back any non-abstract parent models. If you want to control the name of the attribute linking back to the parent, you can create your own OneToOneField and set parent_link=True to indicate that your field is the link back to the parent class.