Skip to content Skip to sidebar Skip to footer

How Do I Properly Format A Stringio Object(python And Django) To Be Inserted Into An Database?

I have a requeriment to store images in the database using django, and for that I created a custom field : from django.db import models class BlobField(models.Field): __metac

Solution 1:

There is no constraint requiring get_db_prep_value to return "printable" characters, or ASCII ones, or otherwise-constrained sets of characters: return any byte string that catches your fancy. You'll get a string in to_python and can make a file-like StringIO instance reading its data with the_instance = StringIO.StringIO(value) (of course you'll need to import StringIO at the top of your module).


Post a Comment for "How Do I Properly Format A Stringio Object(python And Django) To Be Inserted Into An Database?"