I keep getting this error:
SyntaxError: Non-ASCII character '\xe4' in file /var/www/mooimom_django/mooimom_tw/models.py on line 716, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
because of:
subdistrict_destination_text = models.CharField(verbose_name=pgettext_lazy('taiwan-models Shopping_Cart', "Subdistrict Destination Text"), max_length=255, default='100 中正區')
How to solve this problem? thanks
The best way to attack the problem, as with many things in Python, is to be explicit. That means that every string that your code handles needs to be clearly treated as either Unicode or a byte sequence. The most systematic way to accomplish this is to make your code into a Unicode-only clean room.
UTF-8 is one of the most commonly used encodings, and Python often defaults to using it. UTF stands for “Unicode Transformation Format”, and the '8' means that 8-bit values are used in the encoding. (There are also UTF-16 and UTF-32 encodings, but they are less frequently used than UTF-8.)
add this to top of your file:
# -*- coding: utf-8 -*-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With