Django のユーザーのカスタマイズ方法を紹介します。
User作成
users.models にAbstractUserを継承したUserクラスを作成
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
mobile = models.CharField(max_length=11, unique=True)
class Meta:
db_table = ‘tb_user’
設定ファイル変更
project/setting.py
AUTH_USER_MODEL = ‘users.User’
マイグレーション
python manage.py makemigrations
python manage.py migrate
python manage.py migrate