Follow these steps to enhance the User model in the accounts app:
- Add the avatar field and django-imagekit thumbnail specification to the User model:
# myproject/apps/accounts/models.pyimport osfrom imagekit.models import ImageSpecFieldfrom pilkit.processors import ResizeToFillfrom django.utils import timezone# …def upload_to(instance, filename): now = timezone.now() filename_base, filename_ext = os.path.splitext(filename) return "users/{user_id}/{filename}{ext}".format( user_id=instance.pk, filename=now.strftime("%Y%m%d%H%M%S"), ext=filename_ext.lower(), )class User(AbstractUser): # … avatar = models.ImageField(_("Avatar"), upload_to=upload_to, blank=True) avatar_thumbnail = ImageSpecField( source="avatar", processors ...