8

I am using Django 1.5.4 with Django-Regsitration module. whenever I try to register a user with Persian fonts I get this error:

DatabaseError at /accounts/register/
(1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like'")
Request Method: POST
Request URL:    http://127.0.0.1:8000/accounts/register/
Django Version: 1.5.4
Exception Type: DatabaseError

I have the similar problem with other forms that I've created: Whenver I fill a field with Persian font, I get error like:

Warning at /accounts/profile/
Incorrect string value: '\xDA\xA9\xD8\xA7\xD8\xB1...' for column 'occupation' at row 1

To resolve it I did:

Using PhpMyAdmin I've changed collation of the database to 'utf8_general_ci

Had no effect.

I have also enforce the utf8 on the DB:

mysql> ALTER DATABASE djangodb  charset=utf8;

Still no effect.

So appreciate your hints.

supermario
  • 2,625
  • 4
  • 38
  • 58
  • 5
    You need to convert tables also: `ALTER TABLE yourtable CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;` http://stackoverflow.com/questions/1073295/django-character-set-with-mysql-weirdness – nickzam Oct 30 '13 at 23:14
  • Indeed I needed to convert all the tables. This script did the job: http://stackoverflow.com/a/2150335/727695. Feel free to elaborate on the answer and I'll accept it. merci – supermario Oct 30 '13 at 23:32
  • Firstly you need to stop using the 1.X branch of Django. – Andrey Shipilov Jun 24 '19 at 02:39

0 Answers0