There's nothing special about URLconfs-like anything else in Django, they're just Python code. You can take advantage of this in several ways, as described in the sections that follow.
Consider this URLconf, which builds on the example in Chapter 2, Views and URLconfs:
from django.conf.urls import include, url from django.contrib import admin from mysite.views import hello, current_datetime, hours_ahead urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^hello/$', hello), url(r'^time/$', current_datetime), url(r'^time/plus/(\d{1,2})/$', hours_ahead), ]
As explained in Chapter 2, Views and URLconfs, each entry in the URLconf includes its associated view function, passed directly as a function object. This means it's necessary to import the view functions at the top of the module.
But as a Django application grows in complexity, its URLconf...