[Python] Encoding problem when migrating postgresql database tables to models.py django

Discussão em 'Python' iniciado por Stack, Julho 14, 2025.

  1. Stack

    Stack Membro Participativo

    When performing table migration

    python manage.py inspectdb > example/models.py



    all Cyrillic strings are transposed as a set of unknown characters: 'id_шёїюф ∙хую' Encoding of the database server as well as python script is UTF-8. Is there any way to solve this problem?

    I tried

    show server_encoding;


    and got UTF8, tried

    set PYTHONIOENCODING=UTF-8



    Also, I added

    'OPTIONS': {
    'client_encoding': 'UTF8',
    }


    into settings.py. All aforementioned methods didn't help and problem is still existing. I use psycopg package.

    Continue reading...

Compartilhe esta Página