Handy debugging tool and pretty printer for dash.page_registry.
Note that if print_registry() is called from a file in the pages folder, the dash.page_registry
may not be complete.
:param modules: (string or list) Default "ALL". Specifies which modules to print.
:param exclude: (string or list) Default None. Specifies which of the page's parameter(s) to exclude.
:param include: (string or list) Default "ALL". Prints only the parameters that are specified.
Examples:
print_registry() Will print the entire content of dash.page_registry
print_registry("pages.home") will print only one module
print_registry(__name__) will print the current module. If it's run from app.py it will print all modules
print_registry(["pages.home", "pages.archive"]) Will print 2 modules
print_registry(exclude="layout") will print info for all the modules, but will exclude the page["layout"]
print_registry(include=["path", "name"] will print only the page["path"] and page["name"] for all modules
print_registry(exclude="ALL") prints the keys (module names) only
print_registry(include=None) prints the keys (module names) only
Here's an example of print_registry()
from dash import Dash, html, dcc
import dash
import dash_labs as dl
app = Dash(__name__, plugins=[dl.plugins.pages])
dash.register_page("another_home", layout=html.Div("We're home!"), path="/")
dash.register_page(
"very_important", layout=html.Div("Don't miss it!"), path="/important", order=0
)
dl.print_registry()
...
Here is a partial output:
Dash is running on http://127.0.0.1:8050/
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
**Note** When printing from a file in the pages folder, `dash_page_registry` may not be complete. See the "Print page_registry" docs for more info.
{'very_important': {'module': 'very_important',
'supplied_path': '/important',
'path_template': None,
'path': '/important',
'supplied_name': None,
'name': 'Very important',
'supplied_title': None,
'title': 'Very important',
'description': '',
'order': 0,
'supplied_order': 0,
'supplied_layout': Div("Don't miss it!"),
'image': 'app.jpeg',
'supplied_image': None,
'redirect_from': None,
'layout': Div("Don't miss it!")},
'another_home': {'module': 'another_home',
'supplied_path': '/',
'path_template': None,
'path': '/',
'supplied_name': None,
'name': 'Another home',
'supplied_title': None,
'title': 'Another home',
'description': '',
'order': None,
'supplied_order': None,
'supplied_layout': Div("We're home!"),
'image': 'app.jpeg',
'supplied_image': None,
'redirect_from': None,
'layout': Div("We're home!")},
'pages.historical_archive': {'module': 'pages.historical_archive',
Here is an example with pathnames only:
`print_registry(include="path")'
**Note** When printing from a file in the pages folder, `dash_page_registry` may not be complete. See the "Print page_registry" docs for more info.
{'very_important': {'path': '/important'},
'another_home': {'path': '/'},
'pages.historical_archive': {'path': '/historical-archive'},
'pages.not_found_404': {'path': '/404'},
'pages.outlook': {'path': '/forward-outlook'},
'pages.path_variables': {'path': '/asset/inventory/department/branch-1001'},
'pages.query_string': {'path': '/dashboard'},
'pages.redirect': {'path': '/redirect'}}
Handy debugging tool and pretty printer for
dash.page_registry
.Note that if
print_registry()
is called from a file in thepages
folder, thedash.page_registry
may not be complete.:param modules: (string or list) Default "ALL". Specifies which modules to print. :param exclude: (string or list) Default None. Specifies which of the page's parameter(s) to exclude. :param include: (string or list) Default "ALL". Prints only the parameters that are specified.
Examples:
print_registry()
Will print the entire content of dash.page_registryprint_registry("pages.home")
will print only one moduleprint_registry(__name__)
will print the current module. If it's run from app.py it will print all modulesprint_registry(["pages.home", "pages.archive"])
Will print 2 modulesprint_registry(exclude="layout")
will print info for all the modules, but will exclude the page["layout"]print_registry(include=["path", "name"]
will print only the page["path"] and page["name"] for all modulesprint_registry(exclude="ALL")
prints the keys (module names) onlyprint_registry(include=None)
prints the keys (module names) onlyHere's an example of
print_registry()
Here is a partial output:
Here is an example with pathnames only:
`print_registry(include="path")'