I get an error when using BinaryField in sqllite3.

I’m working with data in Blobs in sqlite. It is purely binary (like an image for example) and not information that can be converted to a string.
When I get that data through django’s model, I get the following error:

django.db.utils.OperationalError: Could not decode to UTF-8 column ‘msrepl_synctran_ts’ with text ‘’

I researched quite a bit about this, but there wasn’t much information on the internet.
Please suggest me a workaround.
I don’t need the msrepl_synctran_ts data to be visible/editable in the django model. I just want to load a model with a column called msrepl_synctran_ts.

Hi, you should be able to omit this column in your model definition. Does it work for you?

What specifically do you mean by:

How are you getting the data? What are you trying to do with it?

Are you specifically talking about using this model in the Django admin? (Or somewhere else in your project?)

thank you for your reply.
What @felixxm is saying is that even if it exists as a DB column, it can not be defined as a Model field. I’ll give it a try.

@KenWhitesell
I am getting data with code like below. (The argument to get_context_data is bullshit.)
I get an error when I call all().

from models import MyModel

def get_context_data():
     MyModel.objects.all()

Yes @felixxm is correct that you don’t need to define all columns in your model. (If that’s the case, you’ll also want to set managed=False in the Meta class for that model.)

I can’t recreate the problem you’re describing from the information you’ve provided so far. I regularly store binary data in sqllite and work with it without problems, but I tested it again to make sure.

To pursue this further, I think you’d need to post the model you are using and the schema from the database.

I’m sorry.
After outputting the problematic table to CSV once, deleting it, and then importing the output CSV, the problem disappeared.
When I checked with a binary editor, a certain value changed from 1D to 1C. It looks like there is no difference in the data in SQLite.
It seems that it was not a Django problem but a SQLite DB file problem.
Thanks to the two people who helped me.