M
M
Maxim Gerasimov2018-10-08 12:01:20
PostgreSQL
Maxim Gerasimov, 2018-10-08 12:01:20

How to put value from field of type BinaryField into JS variable in template?

Good afternoon.
The postgresql database is connected to the django project, the model has a field with the type BinaryField, respectively, in the database this field is with the bytea type, the question is: how to transfer the value of the field with the bytea type to javascript in templates?
Django displays the field in the format "memory at 0x03B5F308", passes it in the same form to the JS variable, how to achieve the transfer of the string in binary form to the JS variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Uspensky, 2018-10-12
@MaxGS

Depending on your needs:

select encode (my_field, 'hex') as my_bytes from my_table

select encode (my_field, 'base64') as my_bytes from my_table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question