LoginSignup
2
6

More than 5 years have passed since last update.

Djangoで最初のmigration時に絶対にやるべきこと

Last updated at Posted at 2018-04-22

Python / Django でWebアプリケーションを作成する際に、最初にやっておかなければならないこと、それはUserモデルの拡張です。

まずはこれ

https://torina.top/detail/350/
こちらを参考に、というかそのまま使ってまずはmodels.py、admin.py、settings.pyをカスタマイズします。

その際に、

settings.py
ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx']
省略
INSTALLED_APPS = [
省略
    'accounts',
]

もお忘れなく。

また、上記参考サイトにないのですが、admin.pyには、次の記述も必要です。

admin.py
import accounts

これをファイルの最初に書いておきます。
ちなみに、accountsというのはアプリ名ですので、ご自身のアプリ名に読み替えてください。

これをやってから、migrateします。

その後にSuperUserを作ります。

最初にやらねばならない理由

https://qiita.com/sheep96/items/752acbda64898f20aab2
こちらをご覧ください。

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6