I don't have idea to put extra field in default admin user table/ model in django 3.0.3 version . Please give some idea to make extra field like user_roll, user_id, designation etc.
            Asked
            
        
        
            Active
            
        
            Viewed 109 times
        
    1
            
            
        - 
                    https://stackoverflow.com/a/44178/12261752 – Pruthvi Barot Mar 18 '20 at 09:42
- 
                    1Does this answer your question? [Extending the User model with custom fields in Django](https://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django) – Fourier Mar 18 '20 at 10:52
- 
                    Browsing the doc before and / or doing a search before asking questions is most often a good idea... – bruno desthuilliers Mar 18 '20 at 11:13
1 Answers
1
            
            
        For that you have to extend AbstractUser as below and add extra field as per your requirements...
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
    # Add your extra field here
    my_custom_field = models.CharField(max_length=2)
In this example my_custom_field would be your custom field . You have a number of options, BooleanField (true/fales), IntField ... etc) and you can add as many (within reason, as you like).
And suppose this User model is in app named app_1 then you have to set AUTH_USER_MODEL in settings.py as below...
settings.py
AUTH_USER_MODEL = "app_1.User"
Run makemigrations and migrate commmand because we changed in model.
 
    
    
        AppHandwerker
        
- 1,758
- 12
- 22
 
    
    
        MK Patel
        
- 1,354
- 1
- 7
- 18
- 
                    1Technically, while I get what you're saying here you haven't actually shown him how to add a Field probably want give him an example – AppHandwerker Mar 18 '20 at 10:36
