I have just switched from using running a Django App under Python 3 to Using Python 2.7. I now get this error:
SyntaxError: Non-ASCII character '\xe2' in file /Users/user/Documents/workspace/testpro/testpro/apps/common/models/vendor.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
The code its referring to is just a comment:
class Vendor(BaseModel):
"""
A company manages owns one of more stores.
"""
name = models.CharField(max_length=255)
def __unicode__(self):
return self.name
Why?
This works:
class Vendor(BaseModel):
"""
"""
name = models.CharField(max_length=255)
def __unicode__(self):
return self.name
You have a UTF-8 encoded U+200E LEFT-TO-RIGHT MARK in your docstring:
'\n A company manages owns one of more stores.\xe2\x80\x8e\n '
Either remove that codepoint (and try to use a code editor, not a word processor) from your code, or just put the PEP-263 encoding comment at the top of the file:
# encoding=utf8
Python 3 uses UTF-8 by default, Python 2 defaults to ASCII for source code unless you add that comment.
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