django将yaml utf8 fixture转储到postgresql

时间:2014-04-21 13:33:43

标签: django django-fixtures

我有以下装置:

- model: backoffice.Language
  pk: 1
  fields:
    name: Français
    code: fr

- model: backoffice.Language
  pk: 2
  fields:
    name: English
    code: en

- model: backoffice.Language
  pk: 3
  fields:
    name: ру́сский
    code: ru

我使用以下方法创建了数据库:

CREATE DATABASE xxx_db WITH ENCODING 'UTF8';

但我得到了:

django.core.serializers.base.DeserializationError: Problem installing fixture 'xxx/project_root\backoffice\fixtures\initial_data.yaml': 'charmap' codec can't decode byte 0x81 in position 321: character maps to <undefined>

如果我删除了:

name: ру́сский

并将其替换为

name: russian

Fixture加载但在daytabase中'ç'不正确:

Français

yaml应该默认为utf8。是否与 unicode()或重载某些功能有关?

**编辑**

它不是来自postgresql,因为:

update backoffice_language set name = 'ру́сский' where id = 3;
update backoffice_language set name = 'Français' where id = 1;
select * from backoffice_language;

将显示正确的utf8编码数据。我正在使用django 1.6

0 个答案:

没有答案