Opened 9 years ago

Last modified 9 years ago

#26215 closed Bug

if dumpdata FloatRangeField and IntegerRangeField values = "None" and post loaddata is ValidationError — at Initial Version

Reported by: Алексей Owned by: nobody
Component: contrib.postgres Version: 1.9
Severity: Normal Keywords:
Cc: Алексей Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

  1. FloatRangeField db data == None
  2. ./manage dumpdata
  3. ./manage loaddata

Conversion problem. accept string u'None' to float type

Track:

File "/local/lib/python2.7/site-packages/django/db/models/fields/init.py", line 1803, in to_python

params={'value': value},

Decision:

    def to_python(self, value):
        if value == u'None':
            return None
        elif value is None:
            return value
        try:
            return int(value)
        except (TypeError, ValueError):
            raise exceptions.ValidationError(
                self.error_messages['invalid'],
                code='invalid',
                params={'value': value},
            )

And IntegerField too

Source data dump example:

<field name="rate" type="FloatRangeField">{"upper": "None", "lower": "1.45", "bounds": "[)"}</field>

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top