Abstractuser vs abstractbaseuser in django

Abstractuser vs abstractbaseuser in django


Play all audios:

Loading...

It is important to understand the Difference between ABSTRACTBASEUSE and ABSTRACTUSER in Django, This Article will you to make the right decision on which one to use when you are starting a


Django Project. ABSTRACTUSER AbstractUser class inherits the User class and is used to add Additional Fields required for your User in Database itself. SO its change the schema of the


database. It is basically used to add fields like date_of_birth , location and bio etc. to the existing User model This is Done to the very Beginning of the project. which means you will get


the complete field which by default come with the user Model plus the following field that you add/define. EXAMPLE in the above example you will get all the fields of the User model


additionally the fields we defined here which are date_of_birth , address and bio_info . ABSTRACTBASEUSER ABSTRACTBASEUSER has the authentication functionality only , it has no actual fields


you will supply the fields to use when you subclass. you have to till that what field represent USERNAME fields, and how those users will be managed for example you have to use EMAIL in


your authentication , Normally Django use USERNAME in authentication, so how do you change it to use email? ITS TIME TO DECISION NOW WHICH ONE SHOULD YOU USE ? If you need full control over


USER model, it is better to use ABSTRACTBASEUSER but if you are just adding things to the existing user, for example, you just want to add an extra field bio ,location field or any other


profile data then use ABSTRACTUSER. Thanks For Reading