Why you want to save your images directly on your database? +1 to m1chael say
2013/11/12 m1chael <myk...@gmail.com> > People have always recommended to me that storing images directly in a > database is a bad idea. > > > > On Tue, Nov 12, 2013 at 8:47 AM, Leslie Jeffries > <leslie.jeffr...@gmail.com> wrote: > > Have you looked at this django add-on? > > https://pypi.python.org/pypi/django-db-file-storage > > > > > > On Tuesday, November 12, 2013 3:12:14 AM UTC-5, ckg...@gmail.com wrote: > >> > >> I would like to store images directly into the database i have been > trying > >> this but does not seem to help or i may be doing it in the wrong way'' > >> > >> models.py > >> from database_storage import DatabaseStorage > >> > >> > >> DB_FILES = { > >> 'table': 'files', > >> 'base_url': '/blog/attach/', > >> } > >> > >> > >> class Img(models.model): > >> > >> uploaded_map_16 = models.ImageField(upload_to="map_images", > >> storage=DatabaseStorage(DB_FILES), null=True, blank=True) > >> > >> uploaded_map_17 = models.ImageField(upload_to="map_images", > >> storage=DatabaseStorage(DB_FILES), null=True, blank=True) > >> > >> uploaded_map_18 = models.ImageField(upload_to="map_images", > >> storage=DatabaseStorage(DB_FILES), null=True, blank=True) > >> > >> > >> this is how i am trying to save it: > >> > >> storage = DatabaseStorage(DB_FILES) > >> image_file1 = open(file_name_18, 'rb') > >> file_content1 = image_file1.read() > >> image_file2 = open(file_name_17, 'rb') > >> file_content2 = image_file2.read() > >> image_file3 = open(file_name_16, 'rb') > >> file_content3 = image_file3.read() > >> > >> Img.uploaded_map_18 = storage.save(name + '_18.jpg', file_content1) > >> Img.uploaded_map_17 = storage.save(name + '_17.jpg', file_content2) > >> Img.uploaded_map_16 = storage.save(name + '.jpg', file_content3) > >> > >> Img.save() > >> > >> > > -- > > 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+unsubscr...@googlegroups.com. > > To post to this group, send email to django-users@googlegroups.com. > > Visit this group at http://groups.google.com/group/django-users. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/django-users/b01140fc-1931-4b80-8cb5-5e9625ca265f%40googlegroups.com > . > > > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAAuoY6MBnRkATmhYyYe5%3DDhMyaWbrcC2OLABbhZsTePxuGCE5A%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- Rafael E. Ferrero -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJJc_8Vyuu0YaB45OSQ_rVTwXS%2B37TUTe7bEgRkPShMdFGHOdQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.