Home > Article > Backend Development > How to configure URL when a Django project contains multiple applications
This article mainly introduces the configuration method of URL when the Django project contains multiple applications. It has a certain reference value. Now I share it with you. Friends in need can refer to it
A Django In most cases, there will be multiple applications in the project. How to configure the URLs of multiple applications?
There are two options:
1. Configure different url paths for each application in the urls.py of the Django project
2. Introduce the url configuration file of each application and different urls into the urls.py of the overall project. The paths are configured separately in their respective configuration files
We recommend the second url preparation method:
In the urls.py file of the Django project, introduce the url configuration file of the 'blog' application
In the blog's own urls.py, introduce the views
After that, open the command window in the project path, enter pytyon manage.py runserver to start the Django service,
enter the address localhost:8000/blog, if the following information is displayed, it means the url configuration is successful.
Related recommendations:
Method to directly return the request from Django’s middleware
The above is the detailed content of How to configure URL when a Django project contains multiple applications. For more information, please follow other related articles on the PHP Chinese website!