Extending the User model with custom fields in Django

后端 未结 13 1449
别那么骄傲
别那么骄傲 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条回答
  •  Happy的楠姐
    2020-11-21 23:59

    Simple and effective approach is models.py

    from django.contrib.auth.models import User
    class CustomUser(User):
         profile_pic = models.ImageField(upload_to='...')
         other_field = models.CharField()
    

提交回复
热议问题