On Wed, Feb 11, 2009 at 12:29 PM, Joshua Russo <joshua.rupp...@gmail.com>wrote:
> > Ok, I'm still having issues. > > I'm using Django 1.0.2-final and Python 2.5.4 > > The models.py starts with the proper encoding string of: # -*- coding: > utf-8 -*- > Except apparently your file is not actually encoded in utf-8, see below. > > Here is the line from my models.py that it's tripping up on: > NumTeleMov = models.CharField(u'Numero de telemóvel', max_length=20) Did you really have the u'' there? Because specifying the encoding declaration of utf-8 and using u'' around a string that is not properly utf-8 encoded should have (and does in my tests) generate an error on any attempt to import your models file, not an error later on. > > Here is the trace back: > Environment: > > [snip] File "c:\python25\Lib\site-packages\django\utils\encoding.py" in > force_unicode 70. raise DjangoUnicodeDecodeError(s, *e.args) > Exception Type: DjangoUnicodeDecodeError at /admin/pesoa/pesoa/add/ > Exception Value: 'utf8' codec can't decode bytes in position 15-18: > invalid data. You passed in 'Numero de telem\xf3vel' (<type > 'str'>) > > The fact that the type specified in that error message is <str> also implies you did not have u'' around this string when you got this traceback, because it would have been a unicode string to start with. The error is happening because that string is not utf-8 encoded: Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> s = 'Numero de telem\xf3vel' >>> print unicode(s,'utf8') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "encodings/utf_8.py", line 16, in decode UnicodeDecodeError: 'utf8' codec can't decode bytes in position 15-18: invalid data >>> print unicode(s,'iso8859-1') Numero de telemóvel >>> Looks more likely it is iso8859-1. So, you could change your Python encoding declaration for this file to match the reality of the file (and use u'' around all strings, since Django is going to assume utf-8 for any bytestrings passed to it), or you can re-encode your file to really be in utf-8. How to do that depends on what editor you are using. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---