kopia lustrzana https://github.com/wagtail/wagtail
Add get_site and get_url_parts to the Page model reference docs
rodzic
4dff225d83
commit
7861c2b492
|
@ -95,6 +95,12 @@ In addition to the model fields provided, ``Page`` has many properties and metho
|
|||
|
||||
.. autoattribute:: full_url
|
||||
|
||||
.. automethod:: relative_url
|
||||
|
||||
.. automethod:: get_site
|
||||
|
||||
.. automethod:: get_url_parts
|
||||
|
||||
.. automethod:: route
|
||||
|
||||
.. automethod:: serve
|
||||
|
|
|
@ -749,10 +749,13 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
|
|||
def get_url_parts(self):
|
||||
"""
|
||||
Determine the URL for this page and return it as a tuple of
|
||||
(site_id, site_root_url, page_url_relative_to_site_root).
|
||||
``(site_id, site_root_url, page_url_relative_to_site_root)``.
|
||||
Return None if the page is not routable.
|
||||
|
||||
Pages with custom URL routing should override this.
|
||||
This is used internally by the ``full_url``, ``url``, ``relative_url``
|
||||
and ``get_site`` properties and methods; pages with custom URL routing
|
||||
should override this method in order to have those operations return
|
||||
the custom URLs.
|
||||
"""
|
||||
for (site_id, root_path, root_url) in Site.get_site_root_paths():
|
||||
if self.url_path.startswith(root_path):
|
||||
|
@ -816,6 +819,10 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
|
|||
return root_url + page_path
|
||||
|
||||
def get_site(self):
|
||||
"""
|
||||
Return the Site object that this page belongs to.
|
||||
"""
|
||||
|
||||
url_parts = self.get_url_parts()
|
||||
|
||||
if url_parts is None:
|
||||
|
|
Ładowanie…
Reference in New Issue