Chapter 7. Advanced Views and URLconfs
In Chapter 2, Views and URLconfs, we explained the basics of Django's view functions and URLconfs. This chapter goes into more detail about advanced functionality in those two pieces of the framework.
URLconf Tips and Tricks
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.
Streamlining function imports
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)), ...
Get Mastering Django: Core 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.