Good I am developing a API
by django rest framework
and for this I have configured two databases. I need to make a query
to the second database configured (postgresql) and get it to return the data but it gives me the special characters without decoding. For example for the word "mathematics" it returns "Matem\u00e1ticas"
.
I have tried to make a query outside the environment of django
and using the method conn.set_client_encoding('UTF8')
the problem is solved but in django
I can not find any similar method. I attach the code that works with me outside of django
:
import psycopg2
try:
conn = psycopg2.connect("dbname='XXX' user='XXX' host='XXX' password='XXX'")
except:
print("No ha sido posible conectar a la base de datos")
conn.set_client_encoding('UTF8')
cur = conn.cursor()
cur.execute("""XXX""")
rows = cur.fetchall()
...
And that's how I establish connection to the database in django
conn = connections['XXX']
cur = conn.cursor()
cur.execute("""XXX""")
rows = cur.fetchall()
...
Would there be any equivalent in django
to conn.set_client_encoding('UTF8')
?
I hope someone can help me and thank you.