5.7.2 Using include to Create a Hierarchy of URL Configurations

The second argument passed to url() need not point at a view: it can point at another URL configuration, thanks to the include() function. This capability allows us to create a separate URL configuration in each Django app and have a URL pattern in the site-wide URL configuration point to each one. In effect, the full URL configuration is not a simple list but is actually a tree, where the leaves of the tree are webpages (see Figure 5.6).

Image

Figure 5.6: URL Configuration Tree

When a URL pattern points to a URL configuration, the regular expression pattern acts as a URI prefix. For ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.