DRF Create temporary link to image

48 Views Asked by At

I want to generate temporary link for an image in this model. I already generate link, but want to add a temporary link for everyone which will expired after the time given by user.

class Image(models.Model):
    user = models.ForeignKey(User, related_name="user",
                             on_delete=models.CASCADE)
    title = models.CharField(max_length=255, unique=True)
    alt = models.TextField(null=True)
    date_creation = models.DateTimeField(default=timezone.now)
   
    image = models.ImageField(upload_to=user_directory_path, null=True, blank=True)

Do I have to use hash to code link and store them in database, so create another model for that and after a given time delete it? But what to use to delete object from db after a time?

I want advice or something that will push me to solution

0

There are 0 best solutions below