Extending the User model with custom fields in Django

后端 未结 13 1404
别那么骄傲
别那么骄傲 2020-11-21 23:28

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 (fo

13条回答
  •  伪装坚强ぢ
    2020-11-22 00:09

    The below one is another approach to extend an User. I feel it is more clear,easy,readable then above two approaches.

    http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

    Using above approach:

    1. you don't need to use user.get_profile().newattribute to access the additional information related to the user
    2. you can just directly access additional new attributes via user.newattribute

提交回复
热议问题