I used this project once: http://django-db-file-storage.readthedocs.io/en/latest/
It seems it uses a TextField for the file bytes. I would expect django.contrib.postgres to implement a binary field, but it don't. I guess you can implement your own field type for bytea, psycopg maps bytes to bytea: http://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types In any case I recommend to give this a second thought, the DB is not so efficient to store and serve files as the filesystem is. On Wed, Jan 3, 2018 at 2:19 PM, Jani Tiainen <[email protected]> wrote: > Hi, > > In general it is considered very bad practice to store files in database. > > Could you please tell why you need to store files to database instead of > normal filesystem? > > 3.1.2018 14.03 <[email protected]> kirjoitti: > >> What field should i use to store byte string so that i can later use it >> for ByteIO to convert it into image ? >> >> As this is my first time doing on byte string to image, i am pretty lost >> on what i need to do. >> >> I tried using BinaryField for the image model but when checking the field >> out on Django admin, it gave me this error >> 'image' cannot be specified for MyUser model form as it is a non-editable >> field >> i also tried setting BinaryField(editable=True) but it still doesnt work. >> >> May i have some guidance on how to store the byte string ? >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/django-users/2f787ba8-6c74-4feb-bbdf-f5473acdc835%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/2f787ba8-6c74-4feb-bbdf-f5473acdc835%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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 [email protected]. > To post to this group, send email to [email protected]. > 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/CAHn91odTJHuY%3D71JkTPuX3cV5AsOou-YfqNBf_ > wybfC5yh_dcQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAHn91odTJHuY%3D71JkTPuX3cV5AsOou-YfqNBf_wybfC5yh_dcQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > 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 [email protected]. To post to this group, send email to [email protected]. 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/CAFWa6tKcFf5uZuF%3D7zUyFSo9oOzsBh1VQGZ6-8W4pv_Ti%2B-sjQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

