Hello again
It seems like newforms library has a problem with non unicode charsets
yet.
For example, I use 'windows-1251' character set for my web apps and
MySQL 4.1 with 'cp1251' so actually all data is stored and shown in
cp1251.
And here's what I get when try to save any form with national (non
latin) characters:
>>> from django import newforms as forms
>>> from myproject.models import *
>>> PaymentForm = forms.models.form_for_model(Payment)
>>> user = User.objects.get(pk=1)
>>> form = PaymentForm({'event_date': '2007-01-25', 'user': user.id,
>>> 'description': 'description', 'amount': '100', 'pay_type': 'cash'})
>>> form.is_valid()
True
>>> form.save()
<Payment: description (100)>
>>> form = PaymentForm({'event_date': '2007-01-25', 'user': user.id,
>>> 'description': 'превед, медвед!', 'amount': '100', 'pay_type': 'cash'})
>>> form.is_valid()
True
>>> form.save()
Traceback (most recent call last):
File "<console>", line 1, in ?
File "/usr/lib/python2.4/site-packages/django/newforms/models.py",
line 25, in model_save
obj.save()
File "/usr/lib/python2.4/site-packages/netangels/models/payment.py",
line 26, in save
super(Payment, self).save()
File "/usr/lib/python2.4/site-packages/django/db/models/base.py",
line 204, in save
','.join(placeholders)), db_values)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 148,
in execute
query = query % db.literal(args)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
232, in literal
return self.escape(o, self.encoders)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
179, in unicode_literal
return db.literal(u.encode(unicode_literal.charset))
UnicodeEncodeError: 'latin-1' codec can't encode characters in position
0-5: ordinal not in range(256)
here are my settings:
DATABASE_CHARSET = 'cp1251'
DEFAULT_CHARSET = 'windows-1251'
Any ideas ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---