3

Django documentation says that default collation be 'utf8' but it isn't. Every time I run syncdb to create new tables the default collation of all character fields is 'latin1_swedish_ci'.

The same documentation also says

Django doesn’t provide a way to set this on the model definition.

Is there any other way I can force django's syncdb to use a specific collation with character fields?

user1491229
  • 683
  • 1
  • 9
  • 14

1 Answers1

0

In general ( to change charset and collation ) you could use migrations, something like:

# -*- coding: utf-8 -*-
# Generated by Django 1.11.10
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('some_model', 'A_previous_migration'),
    ]

    operations = [
        migrations.RunSQL('ALTER TABLE some_table CHANGE column_name column_name VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;'),
    ]

Neverless the behaviour you are describing is weird, so maybe there are fancier ways to fix your particular issue.

xpeiro
  • 733
  • 5
  • 21