In case some user requests a page from some Django powered site, the system follows an algorithm that determines which Python code needs to be executed. Here are the steps that sum up the algorithm:
Django first determines which root URLconf or URL configuration module is to be used
Then, that particular Python module is loaded and then Django looks for the variable urlpatterns
These URL patterns are then run by Django, and it stops at the first match of the requested URL
Once that is done, the Django then imports and calls the given view
In case none of the URLs match the requested URL, Django invokes an error-handling view