Introduction
This article’s content will be about how to solve a specific error message. Actually, it has a specific connection with the previous article How to Print All Available URL Routes in Django Application in Microsoft Windows. Turns out that the process for executing the command in the Command Prompt is not as smooth as it will be. In the process for executing the command, the following error appear :
(env) C:\django\myproject>python manage.py show_urls Unknown command: 'show_urls' Type 'manage.py help' for usage. (env) C:\django\myproject>
How to Solve Error Message Unknown command: ‘show_urls’
Actually, the solution is quite simple. The command will not work without the help of an additional Django library. In this context, for solving the error message of Unknown command for the ‘show_urls’ command, it needs the ‘django-extensions’ library. So, in order to be able to use it, the following is an actual step for configuring it :
-
First of all, since the Django project is already exist as in the preparation available in How to Print All Available URL Routes in Django Application in Microsoft Windows previously, just check the environment where the error exist as a reference.
-
In order to solve the error message, it is important to have django-extensions library available. First of all, check it first as in How to Search Package, Module or Library Python using pip_search. So, the following command is checking whether there is a library exist with the nam of ‘django-extensions’ :
(env) C:\django\myproject>pip_search django-extensions 🐍 https://pypi.org/search/?q=django-extensions 🐍 ┌─────────────────────────────┬──────────┬──────────────┬────────────────────────────────────────────────────────────────────────────────────────────────┐ Package Version Released Description ├─────────────────────────────┼──────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────────────┤ 📂 django-extensions 3.2.1 == 09-09-2022 Extensions for Django 📂 extensions 0.4 17-05-2010 Simple plugin system 📂 django-extensions-shell 1.7.4.1 16-09-2016 Isolated shell_plus command from django-extensions 📂 django-rest-extensions 0.2.0 17-07-2022 create normal api for all your models 📂 django-lookup-extensions 0.2.1 09-08-2018 Django lookup extensions use NOT query. 📂 django-orm-extensions 3.0b3 14-05-2012 Advanced improvement of django-orm with a lot of third-party plugins for use different parts of databases are not covered by the standard orm.
As in the above output exist, there is a library with the name of ‘django-extensions’. So, it is possible for further installation.
-
After ensuring that the ‘django-extensions’ exist, just install it as follows :
(env) C:\django\myproject\myapp>python -m pip install django-extensions Collecting django-extensions Using cached django_extensions-3.2.1-py3-none-any.whl (229 kB) Requirement already satisfied: Django>=3.2 in c:\django\env\lib\site-packages (from django-extensions) (4.1.2) Requirement already satisfied: asgiref<4,>=3.5.2 in c:\django\env\lib\site-packages (from Django>=3.2->django-extensions) (3.5.2) Requirement already satisfied: tzdata in c:\django\env\lib\site-packages (from Django>=3.2->django-extensions) (2022.5) Requirement already satisfied: sqlparse>=0.2.2 in c:\django\env\lib\site-packages (from Django>=3.2->django-extensions) (0.4.3) Installing collected packages: django-extensions Successfully installed django-extensions-3.2.1 (env) C:\django\myproject\myapp>
-
Soon after successfully install ‘django-extensions’ library, just register it in the Django project’s configuration. It exist in a file with the name of ‘settings.py’ inside the Django project’s folder. Add the ‘django-extensions’ library as follows :
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', ]
- Finally, execute it once more and if there is no other error message appear, it will display an output as in How to Print All Available URL Routes in Django Application in Microsoft Windows.