text: from django.db import models
  from django.contrib.auth.models import User
  from django.dispatch import receiver
  from django.db.models.signals import post_save
  from PIL import Image
  from django.utils import timezone
  from django.urls import reverse
  
  
  
  # Create your models here.
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
      image = models.ImageField(blank=True, upload_to='profile_pics')
  
      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)
  
      @receiver(post_save,sender=User)
      def create_user_profile(sender,instance,created,**kwargs):
          if created:
              Profile.objects.create(user=instance)
  class Project(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE, default='')
      photo = models.ImageField(upload_to = 'posts/', default='No Image')
      description = models.TextField(max_length=255)
      url = models.TextField(max_length=255)
  
  class Post(models.Model):
      image = models.ImageField(upload_to='posts/')
      title = models.CharField(max_length=100)
      content = models.TextField()
      date_posted = models.DateTimeField(default=timezone.now)
      author = models.ForeignKey(User,on_delete=models.CASCADE)
      url = models.CharField(max_length=50, blank=True)   
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse('post-detail', kwargs={'pk': self.pk})