For the django admin, how do I add a field to the User model and have it editable in the admin?

后端 未结 5 1198
闹比i
闹比i 2021-02-04 10:42

I\'m trying to understand the django admin better and at the same time, I\'m trying to add one more field to the current user admin. In models.py I\'ve done

Use         


        
5条回答
  •  有刺的猬
    2021-02-04 11:17

    It is preferred to write your own user profile class, and attach it to the User model. Then you can use the get_profile() method to retrieve the profile from the user.

    Subclassing the profile admin from an Inline Admin should also allow you to edit the profile on the user's page, which is almost what you're trying to do.

    This post has a really good write-up on the issue: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

提交回复
热议问题