Django - include app urls

To include app urls in Django, follow these steps:

  1. Open your project's main urls.py file. This file is usually located in the project's root directory.

  2. Import the include function from the django.urls module. You can do this by adding the following line at the top of the file: from django.urls import include

  3. In the urlpatterns list, add a new element for each app you want to include. Each element should be a path() function call, with the first argument being the URL pattern you want to match and the second argument being the include() function.

Here's an example: urlpatterns = [ # ... other URL patterns ... path('app/', include('app.urls')), # ... other URL patterns ... ]

In this example, any URL that starts with 'app/' will be passed to the app.urls module for further processing.

  1. Save the file and run your Django server. Now, when a request matches the URL pattern you defined, Django will look for the corresponding views in the app's urls.py file.

That's it! By following these steps, you can include app URLs in your Django project.