How to Print All Available URL Routes in Django Application in Microsoft Windows

Posted on

Introduction

This is an article where the specific content. The content is focusing on how to print or to show all available URL routes exist in Django application. Actually, there is a need to check all available URL route when a Django application is getting quite large. In other words, it may be exist in a situation where there are many URL address. In other words, URL address for routing for every available process. Another situation which is also has a similar condition is whenever there are several Django applications exist. In a Django project, there can be multiple application exist. Quite often, it cause confusion on where the exactly URL route exist. Precisely, locating the the existence of that exact URL in which application is very important. Especially if there are many applications in one single project.

How to Print All Available URL Routes in Django Application

Well, the purpose for printing or displaying all the available URL routes need a certain preparation. It will use a certain setup of the Django project exist in the previous article. Just look the article How to Create Django Project in Microsoft Windows using Command Line. Moreover, an article concerning Django application as a example also exist in How to Create a Django Application inside a Django Project in Microsoft Windows. Just use those two articles as a setup reference for Django project and Django application. Furthermore, below is the actual preparation for simulating on how to print all available URL routes in Django application :

  1. First of all, the in order to setup the environment, install python first. Look at for reference in How to Install Python in Microsoft Windows, How to Install Python 3.10 in Microsoft Windows or How to Install Python in Microsoft Windows 11

  2. Next, install pip tool for installing Django framework where an example exist and available in How to Install pip in Microsoft Windows or in How to Install pip in Microsoft Windows 11

  3. After installing ‘pip’, just create a python virtual environment to isolate the necessary tool, plugin and libraries only for the application. Read How to Create a Python Virtual Environment with a specific version of Python in Microsoft Windows , How to Specify Specific Python Version for Creating a Virtual Python Environment in Microsoft Windows or How to Create Python Virtual Environment from Anaconda in Microsoft Windows as a reference to do it.

  4. Continue on by installing Django. Just look as a reference in How to Install Django in Microsoft Windows.

  5. After that, just create a Django project as in How to Create Django Project in Microsoft Windows using Command Line and a Django application as in How to Create a Django Application inside a Django Project in Microsoft Windows.

After performing all the preparation, the next step is showing how to print all available routes in the Django application. Basically, as an example using a local device running using Microsoft Windows, below are the steps of it :

  1. First of all, just access the Command Prompt as it is the means of the Command Line Interface for accessing the Django application in a local device using Microsoft Windows as its operating system.

  2. Next, just activate the python virtual environment if it is exist. In other words, activate it if only the Django application need that python virtual environment.

  3. Continue on the previous step, execute the following command to print all the URL address available for accessing all the route definition exist in the Django application as follows :
    (env) C:\django\myproject>python manage.py show_urls
    /admin/ django.contrib.admin.sites.index admin:index
    /admin/<app_label>/ django.contrib.admin.sites.app_index admin:app_list
    /admin/<url> django.contrib.admin.sites.catch_all_view
    /admin/auth/group/ django.contrib.admin.options.changelist_view admin:auth_group_changelist
    /admin/auth/group/<path:object_id>/ django.views.generic.base.RedirectView
    /admin/auth/group/<path:object_id>/change/ django.contrib.admin.options.change_view admin:auth_group_change
    /admin/auth/group/<path:object_id>/delete/ django.contrib.admin.options.delete_view admin:auth_group_delete
    /admin/auth/group/<path:object_id>/history/ django.contrib.admin.options.history_view admin:auth_group_history
    /admin/auth/group/add/ django.contrib.admin.options.add_view admin:auth_group_add
    /admin/auth/user/ django.contrib.admin.options.changelist_view admin:auth_user_changelist
    /admin/auth/user/<id>/password/ django.contrib.auth.admin.user_change_password admin:auth_user_password_change
    /admin/auth/user/<path:object_id>/ django.views.generic.base.RedirectView
    /admin/auth/user/<path:object_id>/change/ django.contrib.admin.options.change_view admin:auth_user_change
    /admin/auth/user/<path:object_id>/delete/ django.contrib.admin.options.delete_view admin:auth_user_delete
    /admin/auth/user/<path:object_id>/history/ django.contrib.admin.options.history_view admin:auth_user_history
    /admin/auth/user/add/ django.contrib.auth.admin.add_view admin:auth_user_add
    /admin/autocomplete/ django.contrib.admin.sites.autocomplete_view admin:autocomplete
    /admin/jsi18n/ django.contrib.admin.sites.i18n_javascript admin:jsi18n
    /admin/login/ django.contrib.admin.sites.login admin:login
    /admin/logout/ django.contrib.admin.sites.logout admin:logout
    /admin/password_change/ django.contrib.admin.sites.password_change admin:password_change
    /admin/password_change/done/ django.contrib.admin.sites.password_change_done admin:password_change_done
    /admin/r/<int:content_type_id>/<path:object_id>/ django.contrib.contenttypes.views.shortcut admin:view_on_site
    
    (env) C:\django\myproject>

Leave a Reply