Friday, May 6, 2016

Re: Storing images in a database using Django.

Storing images in a database will be loads of headache later. Like someone else said: store only the paths! Use FileField/imagefield

On May 6, 2016 7:26 PM, "Adam Stein" <adam@csh.rit.edu> wrote:
You can take a look at django-db-file-storage


In my case, I was making something for myself and the hosting server doesn't allow me access to any kind of file system, so I found this.

On Fri, 2016-05-06 at 15:42 -0500, Alex Heyden wrote:
There's an ImageField for use in models, but to really understand it, start with FileField


The general idea is that you have a directory configured by Django's settings that you can use to hold uploaded files. You can also use Django to serve these files if you want. (I tend to use nginx directly for this for performance reasons, but you do what works for you.)

I wouldn't go so far as to say that there's no use case for storing images in databases, but in general, André's advice is solid: store the path instead. Your OS is good at managing files. Let it do its job.

On Fri, May 6, 2016 at 2:53 PM, André Machado <csantos.machado@gmail.com> wrote:
NEVER store images in DB, store its path so you can use it in a img tag later. =)

Em sexta-feira, 6 de maio de 2016 16:06:08 UTC-3, Mlati Mudan escreveu:

Hi guys, I'm a TOTAL noob when it comes to django and web development for that matter. I have an idea for a web app and I do have a basic understanding of programming. I've gone through a few Django tutorials and I'm confident I can do it, I just need help along the way :) 

So, my "brilliant" idea is to make an app for cooking for dummies. Basically, I'd have a repository of recipes. Each recipe consists of: recipe_ID, name, and 10 instruction-photo pairs ("now do this" + photo of that).

The photos are relatively lightweight (less than 50k each) so I think storing them in a database is the way to go. The only snag - I have absolutely no idea how to do it. I've googled a lot but I'm either too thick or my needs are too specific. 

I don't actually need to be able to store the images in the database through the web app. I was thinking of creating folders that contain the pertinent photos and "somehow" storing them in the database for further use. The name of the folder would be the same as the recipe_ID, and the photos would be named recipe_ID_01.jpg, recipe_ID_02.jpg, ...

Thanks in advance for any help you can give me :) 



--   Adam (adam@csh.rit.edu)    

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1462577175.4828.32.camel%40csh.rit.edu.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAuoY6OGTohaj%3Dz4HOB4WLNvTdAyK%3DDBajNN2j2kfz1%3DNEj%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment