简体   繁体   中英

How do i add other fields on Abstract User

This is my model. When i make migrations it is not showing up on my admin page.

 class User(AbstractUser): # TODO User will be associated with one or more chama accounts id_number = models.IntegerField(default=0) phone_number = models.IntegerField(default=0) active_chama = models.ManyToManyField("Chama")

You will have to set the AUTH_USER_MODEL setting in your settings.py if you use the AbstractUser model to create a custom one.

AUTH_USER_MODEL = "myApp.User"

Here is the relevant part in the docs

Edit:

Like stated in the comments you will have to register your custom model in your custom user apps admin.py

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User

admin.site.register(User, UserAdmin)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM