Smiley in url triggers 500 error

31 views
Skip to first unread message

Rob

unread,
Feb 21, 2019, 10:15:41 AM2/21/19
to Django users
Somebody linked our site with a smiley in the url. The url looks like this:
myurl/nummer-333😊🤓/
This results in a 500 error.

Because this page does not exist I expected a 404 error. The 500 error shows:
(1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

Because latin1 doesn't support smileys I converted my database and tables to utf8mb4_unicode_ci (I saw several site advising against using utf8_unicode_ci with mysql)

Then I got this error:
(1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

So the database conversion worked (no other encoding problems with the site) but still the error. I changed my my.cnf to:
[mysqld]
local-infile=0
innodb_file_per_table
bind-address=127.0.0.1
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci

[client]
socket=/usr/local/mysql/data/mysql.sock
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

But still the same error. Anybody an idea?

More info:
Database: mysql  Ver 15.1 Distrib 5.5.46-MariaDB, for Linux (x86_64) using readline 5.1
Django: 1.11.4
Python: 3.4.2

Rob

unread,
Feb 22, 2019, 8:56:10 AM2/22/19
to Django users
Ok solution was simple. I had to add this in settings.py in the database section:
’OPTIONS’: {’charset’: ’utf8mb4’},
Reply all
Reply to author
Forward
0 new messages