Reputation: 74
I have tried this code but always return an empty query, and i don't know why.
parent = MangaPage.objects.filter(title=Page.get_parent)
Upvotes: 0
Views: 816
Reputation: 8023
get_parent
is a method on a specific instance of the Page
class, it's not a property. You should not call it from the Page
class directly, but rather from a specific page.
It should look something like this:
parent = MangaPage.objects.get(title='Some Title').specific().get_parent()
Essentially what you are doing in your code example is searching for a MangaPage
that has a title equal to the method Page.get_parent
, which of course there are none. You need to get the parent of a specific page instance.
Upvotes: 3