Userモデルの継承 前回、Userモデルに追加情報(gender、tel)を与えました。今回は、見栄えの良い方法として、継承を利用してUserモデルをカスタマイズします。 わざわざ継承を利用する理由 DjangoのデフォルトのUserモデルには、usernameというフィールドがあります。しかし、Webアプリによってはusernameとしてemailを利用したい場合があります。今回は、邪魔なusernameフィールドを消してemailをメインに扱うモデルを作成します。 どのモジュールを継承するか? Djangoでは、Userモデルの挙動を継承して変更する際、以下の2つのモジュールを使用する方法があります。 django.contrib.auth.base_user.AbstractBaseUser django.contrib.auth.models.AbstractUser 簡単に継承
Prevent Multiple Sessions for a User in your Django Application Welcome to my first tutorial on this platform. In this one i'm going to show you how to prevent a user account from having multiple sessions at the same time. Whenever a user logs in, the previous sessions is deleted. This approach could be useful in subscription based apps where you want a single access for the subscribing user. Our
今回のテーマは「確認画面付きのトピック作成画面を作る」です。確認画面つき画面とはユーザーの入力した内容を一度表示して必要に応じて入力画面に戻ることができる画面のことです。アンケートページや申込みページでは頻繁に使われますね。これまで使ってきたCreateViewに少し手を加えるだけで簡単に確認画面つきの登録画面が作れますよ。 はじめにお断りしておくと、確認画面の作り方は色々な手法があって、今回ご紹介する方法はあくまで1つの例と捉えていただければと思います。データ保持にセッションを使ったり、URLをページ毎に分ける場合もありますし、ページ遷移はフロントのみ(バックエンドはAPIのみ担う)で対応するなど、ケースごとに対応が異なります。(これは確認画面に限った話ではないですが) ※本ページはFormViewとCreateViewを使うまで読まれた方を対象としています。そのためサンプルソースコード
How can I make a model completely read-only in the admin interface? It's for a kind of log table, where I'm using the admin features to search, sort, filter etc, but there is no need to modify the log. In case this looks like a duplicate, here's not what I'm trying to do: I'm not looking for readonly fields (even making every field readonly would still let you create new records) I'm not looking t
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く