database - How to handle dynamic images in Django? -
for production django website several applications generate graphs/images based on user input data, how should these images handled?
currently each image stored local folders (e.g.
app1/static/app1
,app2/static/app2
) folder upon generation.images copied using
manage.py collectstatic
central folder (e.g.main_app/static/app1
) served (i.e. folder static_root).
the issue images not found in main static folder when dynamically generated i'm relying on collectstatic
move them static_root.
questions:
- should dynamic images served local
main_app/static/app1
folder in production (i.e. change static_root)? - should dynamic images saved main directory folder (e.g.
main_app/static/app1
) instead of relying oncollectstatic
? - should dynamic images handled in other way entirely in production?
directory structure , image locations clarity:
main_app settings.py models.py view.py manage.py /static/app1 (images copied here using `collectstatic`) /static/app2 (images copied here using `collectstatic`) /app1 /static/app1 (images saved here in production) /app2 /static/app2 (images saved here in production)
basis above based on https://docs.djangoproject.com/en/1.8/howto/static-files/deployment/ , spider sense tells me i'm doing wrong. using nginx , gunicorn production.
as neophyte haven't on i'd appreciate tips on terminology (i.e. these don't seem static images @ all, i've found little on dynamic images in documentation).
i suppose takes time generate images, it's idea create task image generation in view , pass task queue, e.g. celery. let create image , save media folder, e.g. local media_root
or remote storage amazon, , add link django model object, uses image. when view requested return link these images amongst other content. see managing files.
your images not static files, if 'recalculated' on time. imo using collectstatic
not best decision in case.
Comments
Post a Comment