Hey, I'm not sure on what the problem is here. I just wanted to let you know that I did the same test on my setup. And it appears to be returning the username as a unicode string.
>>> a = User.objects.get(id = 1) >>> a.username u'admin' I don't have any default-character-set option in my my.cnf file. My User table, and presumably all of my tables, are using the following collation: Collation latin1_swedish_ci Good luck! On Mon, Nov 14, 2011 at 1:31 PM, Nuno Maltez <nuno.li...@gmail.com> wrote: > So, I just ran into a funny issue. I'm using Django + Mysql and when > retrieving users (Auth.user) form the database, the username field > comes as a bytestring while everything else seems to > come as unicode strings: > > >>> from django.contrib.auth.models import User > >>> a=User.objects.get(id=1) > >>> a.username > 'admin' > >>> a.email > u'admin@localhost' > > I know you should only use letters and a few more characters in > usernames, but that seems to be verified in the forms only. I look at > the User model and username, email first and last names > are all CharFields, yet username displays this peculiar behaviour. Any > reason for this? > > I'm using: > mysqld Ver 5.1.41 > Django (1, 3, 1, 'final', 0) > MySQLdb (1,2,3,'final',0) > > > In my.conf used in the connection I have > [client] > default-character-set = utf8 > > and the tables were created with utf8_general_ci > > Thanks in advance, > Nuno > > -- > 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. > > -- 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.