🐍
【Python】Django:jango-extensionsでURLの一覧を確認する方法
達成目標
django-extensions`を用いて、URL一覧を表示させることができる。
URL一覧表示画面
django-extensions
インストール
1.インストールコマンドを実行
ターミナルで実行
docker-compose exec web pip install django-extensions
requirements.txt
に出力
ターミナルで実行
docker-compose exec web pip freeze > requirements.txt
settings.py
の編集
2.
settings.py
のINSTALLED_APPS
に追加
settings.pyのINSTALLED_APPSにdjango_extensionsを追加
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions', # モジュールを追加
]
コンテナの再起動
docker-compose restart
dcoker-compose up
3.URL確認コマンドの実行
テーブル形式で出力してくれる
docker-compose exec web python manage.py show_urls --format=table
or
テーブルでなく一覧で出力してくれる
docker-compose exec web python manage.py show_urls
出力結果
docker-compose exec web python manage.py show_urls
time="2024-11-23T16:32:07+09:00" level=warning msg="C:\\Users\\shimo\\Desktop\\test\\reha_navi\\docker-compose.yml: `version` is obsolete"
/ django.views.generic.base.TemplateView home
/accounts/confirm-email/ allauth.account.views.EmailVerificationSentView account_email_verification_sent
/accounts/confirm-email/<key>/ allauth.account.views.ConfirmEmailView account_confirm_email
/accounts/email/ allauth.account.views.EmailView account_email
/accounts/google/login/ allauth.socialaccount.providers.oauth2.views.view google_login
/accounts/google/login/callback/ allauth.socialaccount.providers.oauth2.views.view google_callback
/accounts/inactive/ allauth.account.views.AccountInactiveView account_inactive
/accounts/login/ allauth.account.views.LoginView account_login
/accounts/logout/ allauth.account.views.LogoutView account_logout
/accounts/password/change/ allauth.account.views.PasswordChangeView account_change_password
/accounts/password/reset/ allauth.account.views.PasswordResetView account_reset_password
/accounts/password/reset/done/ allauth.account.views.PasswordResetDoneView account_reset_password_done
/accounts/password/reset/key/<uidb36>-<key>/ allauth.account.views.PasswordResetFromKeyView account_reset_password_from_key
/accounts/password/reset/key/done/ allauth.account.views.PasswordResetFromKeyDoneView account_reset_password_from_key_done
/accounts/password/set/ allauth.account.views.PasswordSetView account_set_password
/accounts/signup/ allauth.account.views.SignupView account_signup
Discussion