Skip to main content

Print registered urls in a readable format.

Project description

Urlmapper is a library for Django to print out the registered urls for a site in a readable format.

Basic Usage

from mysite.urls import urlpatterns
from urlmapper.utils import get_urls

urls = get_urls(urlpatterns)

for entry in urls:
    print(entry["path"], entry["name"], entry["view"])

A urlpattern like:

extra = [
    url("^world/$", view),
]

nested = [
    url(r"^(?P<slug>\w+)/", include([
        url(r"^$", view),
        url(r"^history/$", view),
        url(r"^edit/$", view),
    ])),
]

urlpatterns = [
    url("^$", view),
    url("^product/(?P<slug>[^/]+)/$", view, name="product-detail"),
    url("^about/$", view, name="about"),
    url("^hello/", include(extra)),
    url("^page/", include(nested)),
]

Would output like:

/
/about/
/hello/world/
/page/<slug>/
/page/<slug>/edit/
/page/<slug>/history/
/product/<slug>/

Installation

Urlmapper can be installed from PyPI:

pip install django-urlmapper

Credits

This code was originally modified from the django-extensions library for use in things other than Django management commands.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-urlmapper-1.1.0.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file django-urlmapper-1.1.0.tar.gz.

File metadata

File hashes

Hashes for django-urlmapper-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8aeb3f4033155b8912791d8dc7492e423f7a5fbf28ec44e3b1293c68a165002c
MD5 097d42e3db3d6fe95675457fe85d8202
BLAKE2b-256 11ff8e08a3c5ed4147ad44fe7142d7681209249e34aeed9375c390a097817274

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page