Django Binary or BLOB field

I have a C # program that inserts a PDF inside a MySQL database. Now I want to get this pdf file through django, but django models.FileField needs the β€œDownload” parameter, which means that behind the scenes it actually stores the file in the file system, not the database. Is there a way to create a django model so that I can store the PDF directly in MySQL?

Hi

+7
source share
2 answers

I dealt with the same problem by writing a pdf file for the mediumblob field in mysql and extracting through django. I set the mysql field type for the mediumblob field and django for the text field. I used the request and httpresponse to view PDF objects in a browser (but not directly in django).

+1
source

Like the update to this, starting with Django 1.6, there is now the BinaryField option, which will store files up to 4 GB in size. https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.BinaryField

+12
source

All Articles