django==1.11.9
mysql version 5.6.38
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
I have an accent field in my data, and I set the unique field. However, multiple results will appear in the query. Although I know you can by ALTER TABLE test DEFAULT COLLATE utf8_bin;
set the table properties. But I think the better way is through the query to add conditions SELECT * FROM test WHERE name = 'a' collate utf8_bin;
.
Now I don't know how to use it in the queryset method. When I was in inserting data usually use update_or_create()
method, which will directly lead to some other form (with accent) data is not inserted into it.
Can this query condition be extended in Django's queryset method?