技術ブログ「Python」
Python [Django] allauthでメール検証(verification)を送信方法
前提 以下の記事の内容を先に完了していることをオススメする。 1. https://shimidai.com/djangoallauthbasically/ 2. https://shimidai.c…
Python [Django] allauthのtemplatesのHTMLをカスタマイズする方法
前提 以下の記事の内容を先に完了している必要がある。 1. https://shimidai.com/djangoallauthbasically/ 2. https://shimidai.com/d…
Python [Django] allauthで/logoutにアクセスしたらログアウト状態にする方法
前提 以下の記事の内容を先に完了している必要がある。 1. https://shimidai.com/djangoallauthbasically/ 2. https://shimidai.com/d…
Python [Django] メール送信する方法。SMTP利用とconsole利用について
SMTPの場合 settings.pyに以下を追記。 For email EMAILBACKEND = 'django.core.mail.backends.smtp.EmailBackend' EM…
Python [Django] 最もシンプルなファイルアップロード機能をファンクションベースで作成
ソース settings.pyにMEDIAROOLを追加 MEDIAROOT = os.path.joinBASEDIR, 'media' MEDIAURL = '/media/' forms.pyを…
Python [Django] ModelのDatatimeにtimzezoneでデータを挿入する時はdjango.utils.timezoneを使う
Pythonのdatatimeにはnativeとawareが存在 nativeはタイムゾーンを持たない datetime awareはタイムゾーンを持つ datetime ベストプラクティスはawar…
Python [Django] Admin画面にModelを”日本語”で表示する方法とs付きをなくす方法
前提 https://shimidai.com/djangosettingmodelinadmin/ を事前に実施しておく必要がある 日本語(別名)で表示 verbosename を指定することで日本…
Python [Django][Celery] {"exc_type": "NotRegistered", "exc_message": ["tasks.tasks.xxx"], "exc_module": "celery.exceptions"}が出た時の対処方法と理由
対処方法 CeleryのWorker とBroker を再起動するば良い。 発生理由 以下のようにtaskを作成すると from celery import sharedtask import fcm…
Python [Django] Generic detail view XXXDetailView must be called with either an object pk or a slug in the URLconf. の解決方法
解消方法 Generic detail view XXXXDetailView must be called with either an object pk or a slug in the URL…
Python FCM+Python(firebase_admin)を使用してスマホ/WebにPUSH通知
前提 FMCのプロジェクトが作成されていること アプリ構成やウェブプッシュ証明書が正しく設定されていること iOSやAndroidの登録デバイスが取得できていること インストール firebasead…
Python [Django] datadump/loaddataでデータのエクスポート/インポート
datadumpでエクスポート 全てをエクスポート python manage.py dumpdata polls polls/fixtures/dumpdata.json 特定のModelをエクスポ…
Python [Django] ログイン中のユーザ情報を取得
利用シーン ログイン中のユーザ情報で処理を変えたい ログイン中のユーザ情報をcontextdatactxをTemplateに渡したい ログイン情報を元に別のデータを取得する ファンクションベースビュー…