NotImplementedError: This backend doesn't support absolute paths.

502 views
Skip to first unread message

Soumen Khatua

unread,
Mar 3, 2020, 3:16:11 AM3/3/20
to django...@googlegroups.com
Hi Folks,

I'm using AWS S3 Bucket to store media folder(images) but I want to resize each every image in 300*300. So, I'm overriding the save method inside django model class. But I'm getting one error caled:
   NotImplementedError: This backend doesn't support absolute paths.

My django models look like:

 class Profile(models.Model):
    user = models.OneToOneField(
        AUTH_USER_MODEL,
        on_delete=models.CASCADE,
        related_name="profile"
    )
    profile_pic = models.ImageField(default = 'profile.jpg',upload_to = user_directory_path, null = True)

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        img = Image.open(self.profile_pic.path)
        if img.height > 300 or img.width > 300:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.image.path)




I don't know how to solve this issue.

Thank you in advance

Regards,
soumen

Naveen Arora

unread,
Mar 3, 2020, 4:31:26 AM3/3/20
to Django users
Try passing a relative path, as the error itself says, absolute path not supported.

Thanks

Soumen Khatua

unread,
Mar 3, 2020, 8:45:56 AM3/3/20
to django...@googlegroups.com
after changing the path still I'm getting the same type of error.

Thank you for your response.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c207b85c-c966-43c5-8c23-14084bb4a979%40googlegroups.com.

Naveen Arora

unread,
Mar 4, 2020, 1:26:17 AM3/4/20
to Django users
Can you share the complete traceback of error + what are you passing and where so that i can understand the flow. ?

Cheers
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Soumen Khatua

unread,
Mar 4, 2020, 1:31:26 AM3/4/20
to django...@googlegroups.com
okay..sure

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b7a29a2-8987-4169-9d4c-d6879fc35c46%40googlegroups.com.

Soumen Khatua

unread,
Mar 4, 2020, 1:42:52 AM3/4/20
to django...@googlegroups.com
    obj.save(force_insert=True, using=self.db)
TypeError: save() got an unexpected keyword argument 'force_insert'
[04/Mar/2020 12:11:16] "POST /register/ HTTP/1.1" 500 108601

Soumen Khatua

unread,
Mar 4, 2020, 2:34:29 AM3/4/20
to django...@googlegroups.com
Could you tell me how I can save image in aws S3 bucket after resizing the image into some random pixels??


Thank you
Reply all
Reply to author
Forward
0 new messages