1

I want to override the route method from the Page wagtail model inside one of my models but it seems that it doesn't work, i am aware of the RoutablePageMixin that isn't what i want,Basically i tried to do something similar to what is in the wagtail's doc like this:

class Echoer(Page):

    def route(self, request, path_components):
        print('inside route method')
        .
        .
        .

but i never see that print statement get executed when a request arrive for that page, can anyone please explain what is going on?Thank you

Alan Omar
  • 4,023
  • 1
  • 9
  • 20
  • Possible duplicate of [In Python, how do I indicate I'm overriding a method?](https://stackoverflow.com/questions/1167617/in-python-how-do-i-indicate-im-overriding-a-method) – juankysmith May 22 '19 at 12:51
  • Thank you @juankysmith , please have a look at wagtail's doc link. – Alan Omar May 22 '19 at 13:17
  • 1
    Just tried the same code here (with `return super().route(request, path_components)` after the print), and it's working for me. Are you sure you're visiting the URL of a page of type `Echoer`? – gasman May 22 '19 at 13:23
  • Hello @gasman after doing some researches i discovered that the route method inside my model was this method: def _new_route(self, request, path_components): """ Rewrite route method in order to handle languages fallbacks """ # copied from wagtail/contrib/wag . . and this was the result of adding my model to translation.py. not the route method from the Page model which i was trying to override. – Alan Omar May 23 '19 at 11:09

0 Answers0