Customize User Model in Python Django

Youtube video for Customize User Model in Python Django

models.py


from django.db import models
from django.contrib.auth.models import AbstractUser

class CustomUser(AbstractUser):
    USER = (
        (1,'HOD'),
        (2,'STAFF'),
        (3,'STUDENT'),
    )


    user_type = models.CharField(choices=USER,max_length=50,default=1)
    profile_pic = models.ImageField(upload_to='media/profile_pic')

how to install pillow module

pip install pillow

settings.py

AUTH_USER_MODEL = 'app.CustomUser'

admin.py


from django.contrib import admin
from .models import *
from django.contrib.auth.admin import UserAdmin

class UserModel(UserAdmin):
    list_display = ['username','user_type']
    
admin.site.register(CustomUser,UserModel) 	

Tags

#pythonlife #pythonprojects #pythonlanguage #pythonsnake #pythontutorial #pythonbaba #pythoninhindi #python3 #pythonbasics #pythoncourse #pythonclass11cbse #pythonclassattenkasi #pythoncode #pythoncoding #pythonchatbot #pythoncowboy #pythondash #pythondatasciencetutorial #pythondjango #pythonedureka #pythonessentials #pythonfrieght #pythonforbegginers #pythonforbeginners #pythonfordatascience #pythonfullcourse #pythonfullstackdevelopercourseinbangalore #pythonfullstackdevelopercourseinhyderabad #pythonfundamentals #pythongui #pythongraphics #pythonguitutorial #pythonhunting #pythonintelugu #pythonimageprocessing #pythonintree #pythoninterview #pythoninonevideo #pythoninterviewquestions #pythonintro #pythonjarvis #pythonkannada #pythonloginsystem #pythonlogintkinter #pythonlanguagefordsssbexam #pythonmockinterview #pythonmachinelearning #pythonmcq #pythonmalayalam #pythononlinetraining #pythonprojectusingsqlconnectivity #pythonprogrammingforbeginners #pythonprogrammingfullcourse #pythonprojectideas #pythonprogramming #pythonprograms #pythonprogramsintamil #pythonregex #pythonrevisiontour #pythonrightnow

Post a Comment

Previous Post Next Post

Contact Form