Now is a good time to point out the philosophy behind Django and URL configuration: the loose coupling principle. Simply put, loose coupling is an important software development method that guarantees interchangeability.
The Django URL configuration is a good example. In a Django application, the definition of the URL and the view function are loosely coupled, in other words, deciding which view function the URL returns and implementing this view function is in two different places. This allows the developer to modify a piece without affecting another piece.
For example, consider the Current_datetime view. If we want to change its URL from the original/time/to/currenttime/, we just need to quickly modify the URL configuration, do not worry about the internal implementation of this function. Similarly, if we want to modify the internal implementation of this function, we do not have to worry about the corresponding URL.
In addition, if we want to output this function to some URLs, we just need to modify the URL configuration without having to change the view's code. In this example, Current_datetime is used by two URLs. This is a case in point, but this method will be used sooner or later.
Urlpatterns = Patterns (' ^hello/$ ', hello), (' ^time/$ ', current_datetime), (' ^another-time-page/$ ') , Current_datetime),)