#20251: UnicodeEncodeError with DecimalField
---------------------------+--------------------------------------
     Reporter:  anonymous  |                    Owner:  nobody
         Type:  Bug        |                   Status:  closed
    Component:  Forms      |                  Version:  1.5
     Severity:  Normal     |               Resolution:  invalid
     Keywords:             |             Triage Stage:  Unreviewed
    Has patch:  0          |      Needs documentation:  0
  Needs tests:  0          |  Patch needs improvement:  0
Easy pickings:  0          |                    UI/UX:  0
---------------------------+--------------------------------------

Comment (by anonymous):

 {{{
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 import sys
 import os

 os.environ['DJANGO_SETTINGS_MODULE'] = 'agu.settings'

 from agu import settings
 from django import forms

 class TestForm(forms.Form):
     field = forms.DecimalField()

 data = {'field': u"1 грн"}
 form = TestForm(data)
 if form.is_valid():
     print(form.cleaned_data)
 else:
     print('Invalid form')

 }}}

 Runing on Windows7 64bit, python 2.7, Django 1.5

 {{{
 Traceback (most recent call last):
   File "temp.py", line 19, in <module>
     if form.is_valid():
   File "C:\Python\lib\site-packages\django\forms\forms.py", line 126, in
 is_valid
     return self.is_bound and not bool(self.errors)
   File "C:\Python\lib\site-packages\django\forms\forms.py", line 117, in
 _get_errors
     self.full_clean()
   File "C:\Python\lib\site-packages\django\forms\forms.py", line 272, in
 full_clean
     self._clean_fields()
   File "C:\Python\lib\site-packages\django\forms\forms.py", line 287, in
 _clean_fields
     value = field.clean(value)
   File "C:\Python\lib\site-packages\django\forms\fields.py", line 154, in
 clean
     value = self.to_python(value)
   File "C:\Python\lib\site-packages\django\forms\fields.py", line 293, in
 to_python
     value = Decimal(value)
 UnicodeEncodeError: 'decimal' codec can't encode characters in position
 2-4: invalid decimal Unicode string
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20251#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to