Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-table model inheritance using parent_link not working #48

Open
jackappleby opened this issue Jul 26, 2016 · 1 comment
Open

Multi-table model inheritance using parent_link not working #48

jackappleby opened this issue Jul 26, 2016 · 1 comment

Comments

@jackappleby
Copy link

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. But I get this error when I use it:

websites.Text: (models.E015) 'ordering' refers to the non-existent field 'position'.

I've tried various field names such as websitecontentitem_ptr, websitecontentitem_ptr_id etc but no luck. What am I doing wrong?

@jpwatts
Copy link
Owner

jpwatts commented Sep 17, 2016

I should say up front that I'm not actively using this project anymore, so I'm probably not going to be able to help all that much. I also haven't been involved in any recent maintenance, so I can't speak for how well the project has tracked changes to Django, etc. It's entirely possible that things have changed enough that using this code is now more trouble than it's worth.

That said, I was able to reproduce your issue when running makemigrations. I found two ways to get past the error:

  1. Add abstract = True to ContentItem.Meta
  2. Remove ordering = ['position'] from ContentItem.Meta and plan to rely on Text.objects.order_by('position')

If an abstract base model is appropriate for your use case, that's probably the option I would choose.

Good luck with your project. I wish I could be more helpful, but I can't afford the time away from other priorities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants