The user model is as follows.
class User(AbstractUser): username = None email = models.EmailField('email address', unique=True) first_name = models.CharField('First Name', max_length=255, blank=True, null=False) last_name = models.CharField('Last Name', max_length=255, blank=True, null=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username']
The user profile model is as follows.
class UserProfile(models.Model): user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE) avatar = models.ImageField(upload_to=avatar_image, blank=True, null=True)
This makes sense. Please note that django uses the
PIL
library to handle imagesIn your virtual environment
pip install pillow
In yourmodels.py
Images are handled as static files. Handling static files is described here