Django and AWS S3 returns This backend doesn't support absolute paths

I am working on a Django project whereby when users register their profiles get automatically created using the signals.py. Everything works fine in the localhost, but now I want to migrate to the AWS S3 bucket before deploying my project to Heroku. After configuring my AWS settings in settings.py, I get the error NotImplementedError: This backend doesn't support absolute paths. after trying to create a superuser through the python manage.py createsuperuser command.

Here is my models.py:

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    avatar = models.ImageField(default='default.jpg', null=True, blank=True)
    bio = models.TextField()
    resume= models.FileField('Upload Resumes', upload_to='uploads/resumes/', null=True, blank=True,default='resume.docx')

Here is the signals.py:

@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)


@receiver(post_save, sender=User)
def save_profile(sender, instance, **kwargs):
    instance.profile.save()

And here is my settings.py;

# S3 BUCKETS CONFIG 
AWS_ACCESS_KEY_ID=''
AWS_SECRET_ACCESS_KEY=''
AWS_STORAGE_BUCKET_NAME=''

# Storages configuration
AWS_S3_FILE_OVERWRITE= False
# AWS_DEFAULT_ACL = None
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
# STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

# Only public read for now
AWS_QUERYSTRING_AUTH = False
AWS_DEFAULT_ACL='public-read'

STATIC_URL = '/static/'

Inside the s3 bucket, I have the default.jpg and resume.docx in the root folder. Any assistance will be highly appreciated. Thanks.

Answering my own question. So, I solved this problem by following the procedure shared in this quest. Thanks to Bamagujen_Bahaushe in the comments for leading me into this link.

Back to Top