How to handle non-uploaded dynamic images ?

8 views
Skip to first unread message

Dorian LE NET

unread,
May 8, 2020, 10:23:13 PM5/8/20
to Django users
Let's say I have a django app where users can display images by choosing among infinite parameters through a form. These images do not exist before the user generate them as they are built accordingly to its selection of parameters. Such images are dynamically and internally generated. Then they are neither static nor uploaded by users.


How should I store such images ? As static images, as media images or as a customized category ?


As images are internally generated and not uploaded by users, it does not seem necessary to use the file storage systems and the /media/ location. But it does not seem clever to use the /static/ directory either, as many images will be added (and removed) - they are not static by definition.


I would also like to use a model that contains these images and other information about them. What model field class should I use to handle them ? As the images are not uploaded by users models.ImageField does not seem appropriate.


Thank you

Ryan Nowakowski

unread,
May 12, 2020, 10:41:32 AM5/12/20
to Django users
On Fri, May 08, 2020 at 06:47:22PM -0700, Dorian LE NET wrote:
> Let's say I have a django app where users can display images by choosing
> among infinite parameters through a form. These images do not exist before
> the user generate them as they are built accordingly to its selection of
> parameters. Such images are dynamically and internally generated. Then they
> are neither static nor uploaded by users.
>
>
> How should I store such images ? As *static* images, as *media* images or
> as a customized category ?
>
>
> As images are internally generated and not uploaded by users, it does not
> seem necessary to use the file storage systems and the /media/ location.
> But it does not seem clever to use the /static/ directory either, as many
> images will be added (and removed) - they are not static by definition.
>
>
> I would also like to use a model that contains these images and other
> information about them. What model field class should I use to handle them
> ? As the images are not uploaded by users models.ImageField does not seem
> appropriate.

My rule of thumb is that if an image is referenced in the database then
it goes under "media".
Reply all
Reply to author
Forward
0 new messages