Saturday, 15 August 2015

python - Determine complete Django url configuration -


Is complete any way to get the DNS URL configuration?

For example, the Debuging 404 page of DjGo does not include the URL configuration, so it is not a complete configuration.

"" * Depth, entry. Arghte Pete Tern If the hat-trar (entry, 'url_patterns'): show_arls (entry.url_patterns, depth + 1) show_urs (url.retlatpatrans)

Django is Python, so introspection is your friend.

In the shell, import urls . By looping through urls.urlpatterns and possibly by drilling through several layers of URL configurations, you can create a full URL configuration.

urls.urlpatterns

list urls.urlpatterns in the RegexURLPattern and RegexURLResolver objects.

For a RegexURLPattern object p you can display with regular expression

  P.regex. Pattern  

For a RegexURLResolver object q , which represents an included url configuration, you can display the first part Regular expression with

  q.regex.pattern  

  q.url_patterns  Use 

will return another list of RegexURLResolver and RegexURLPattern items .


No comments:

Post a Comment