django-custom-user

Using Django auth UserAdmin for a custom user model

瘦欲@ 提交于 2019-11-27 10:09:33
From the Django.Contrib.Auth docs : Extending Django’s default User If you’re entirely happy with Django’s User model and you just want to add some additional profile information, you can simply subclass django.contrib.auth.models.AbstractUser and add your custom profile fields. This class provides the full implementation of the default User as an abstract model. Said and done. I created a new model like below: class MyUser(AbstractUser): some_extra_data = models.CharField(max_length=100, blank=True) This shows up in admin almost like Django's standard User . However, the most important

Using Django auth UserAdmin for a custom user model

泄露秘密 提交于 2019-11-26 15:02:39
问题 From the Django.Contrib.Auth docs: Extending Django’s default User If you’re entirely happy with Django’s User model and you just want to add some additional profile information, you can simply subclass django.contrib.auth.models.AbstractUser and add your custom profile fields. This class provides the full implementation of the default User as an abstract model. Said and done. I created a new model like below: class MyUser(AbstractUser): some_extra_data = models.CharField(max_length=100,