def get_url(self): # NOTE: you can call `url_for` directly from the templates if not self.date: return '' return url_for('blog.views.note', year=self.date.year, month='{0:02}'.format(self.date.month), slug=self.slug)
def _get_page_url(self, page): url = url_for(self.endpoint, page=page, **self.kwargs) if url: # page is a part of URL: /foo/page1/ return url else: # page is just a param: /foo?page=x return Href('.')(page=page)