django-authentication

Extending the User model with custom fields in Django

ぐ巨炮叔叔 提交于 2019-11-26 01:19:06
问题 What\'s the best way to extend the User model (bundled with Django\'s authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I\'ve already seen a few ways to do it, but can\'t decide on which one is the best. 回答1: The least painful and indeed Django-recommended way of doing this is through a OneToOneField(User) property. Extending the existing User model … If you wish to store information related to User , you can use