1đź‘Ť
No.Not good, especially as it scales.
When you think about what happens in the request/response cycle you’ll know that your python scripts get interpreted by some modules. So if you’re using apache for instance, mod_wsgi could be doing this work.
Usually, you don’t want your static files being served by this same process because that is not very efficient, static files being static. In a typical scenario, you’ll want a very fast web server, say nginx serving your static content without “thinking”. This delegation gives a very efficient and scalable design. As @Anentropic said, you could choose to host static media on a CDN.
2đź‘Ť
in short: no.
use Django’s built in ImageField and have your webserver serve the files from disk.
Alternatively you can use ImageField with a custom storage backend such as django-storages and put the files up on e.g. Amazon S3 and have them served from there (maybe adding something like CloudFront CDN in front)
1đź‘Ť
The best way to do this is to store the images in your server in some specific, general folder for this images. After that you store a string in your DB with the path to the image that you want to load. This will be a more efficient way to do this.
- [Django]-Python model inheritance and order of model declaration
- [Django]-Custom metrics from celery workers into prometheus
- [Django]-Where to put Django comments moderation code?
- [Django]-How to dumpdata from django-tenant-schemas?