I have field:
image = models.ImageField(
max_length=500,
upload_to='images'
)
and some settings to upload an image to AWS S3 Bucket, where PublicMediaStorage is my custom storage:
PUBLIC_MEDIA_LOCATION = 'media'
AWS_S3_MEDIA_ENDPOINT_URL = env('AWS_S3_MEDIA_ENDPOINT_URL', None)
DEFAULT_FILE_STORAGE = 'new_project.storages.PublicMediaStorage'
I need to store and get my images from database(postgres).
For now my image stores at the database like
here.
And if i write image.url i will get the url of my image(that's why I don't need to store urls of images in my database).
But is it right way? Maybe it will be better to store immediately links at the database? Any solutions?