text: from django.db import models
  from django.contrib.auth.models import User
  # from tinymce.models import HTMLField
  from django.db.models.signals import post_save
  from django.dispatch import receiver
  
  from PIL import Image
  # Create your models here.
  
  class Post(models.Model):
      author = models.ForeignKey(User, on_delete=models.CASCADE)
      image = models.ImageField(upload_to='posts')
      caption = models.CharField(max_length=255)
      likes = models.IntegerField(default=0)
  
      def __str__(self):
          return f'{self.author.username} post'
      
      def save(self, *args, **kwargs):
          super().save(*args, **kwargs)
  
          img = Image.open(self.image.path)
          if img.height > 300 or img.width > 300:
              output_size = (300, 300)
              img.thumbnail(output_size)
              img.save(self.image.path)
  
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      image = models.ImageField(default='default.png', upload_to='profile_pics')
      profile_caption = models.CharField(max_length=255)
  
      def __str__(self):
          return f'{self.user.username} Profile'
  
      def save(self, *args, **kwargs):
          super().save(*args, **kwargs)
  
          img = Image.open(self.image.path)
          if img.height > 300 or img.width > 300:
              output_size = (300, 300)
              img.thumbnail(output_size)
              img.save(self.image.path)
  
  
  class Comment(models.Model):
      author = models.ForeignKey(User, on_delete=models.CASCADE)
      post = models.ForeignKey(Post, on_delete=models.Case)
      body = models.TextField(max_length=500, blank=False)
  
      def __str__(self):
          return self.body