Starting with urls.py
Even if you have access to the entire source code of a Django site, figuring out how it works across various apps can be daunting. It is often best to start from the root urls.py
URLconf
file since it is literally a map that ties every request to the respective views.
With normal Python programs, I often start reading from the start of its execution—say, from the top-level main module or wherever the __main__
check idiom starts. In the case of Django applications, I usually start with urls.py
since it is easier to follow the flow of execution based on various URL patterns a site has.
In Linux, you can use the following find
command to locate the settings.py
file and the corresponding line specifying the root urls.py
:
$ find ...
Get Django: Web Development with Python 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.