Skip to content

Instantly share code, notes, and snippets.

@Adarshreddyash
Created August 3, 2020 16:28
Show Gist options
  • Select an option

  • Save Adarshreddyash/70f0e27dce91fcfcc8904c808739de0e to your computer and use it in GitHub Desktop.

Select an option

Save Adarshreddyash/70f0e27dce91fcfcc8904c808739de0e to your computer and use it in GitHub Desktop.
from django.db import models
# Create your models here.
from django.contrib.auth.models import AbstractUser
from django.utils.translation import ugettext_lazy as _
from .managers import CustomUserManager
class CustomUser(AbstractUser):
username = None
email = models.EmailField(_('email address'), unique=True)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
objects = CustomUserManager()
profile_name = models.CharField(blank=True, max_length=100)
avatar = models.ImageField(upload_to='avatars/', null=True, blank=True)
def set_avatar(self):
avatar = self.avatar
if not avatar:
self.avatar="------REPLACE THIS WITH YOUR DEFAULT AVATAR URL-----"
def __str__(self):
return self.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment