#NEWLINE# def test_how_to_convert_decimal_fields( self ) : #NEWLINE# #INDENT# 'Demonstrates migrating from 0.7 to 0.8\n        ' #NEWLINE# class Person ( Document ) : #NEWLINE# #INDENT# name = StringField ( ) #NEWLINE# money = DecimalField ( force_string = True ) #NEWLINE# monies = ListField ( DecimalField ( force_string = True ) ) #NEWLINE# #UNINDENT# Person . drop_collection ( ) #NEWLINE# Person ( name = 'Wilson Jr' , money = Decimal ( '2.50' ) , monies = [ Decimal ( '2.10' ) , Decimal ( '5.00' ) ] ) . save ( ) #NEWLINE# class Person ( Document ) : #NEWLINE# #INDENT# name = StringField ( ) #NEWLINE# money = DecimalField ( precision = 2 , rounding = decimal . ROUND_HALF_UP ) #NEWLINE# monies = ListField ( DecimalField ( precision = 2 , rounding = decimal . ROUND_HALF_UP ) ) #NEWLINE# #UNINDENT# for p in Person . objects : #NEWLINE# #INDENT# p . _mark_as_changed ( 'money' ) #NEWLINE# p . _mark_as_changed ( 'monies' ) #NEWLINE# p . save ( ) #NEWLINE# #UNINDENT# wilson = Person . objects ( name = 'Wilson Jr' ) . as_pymongo ( ) [ 0 ] #NEWLINE# self . assertTrue ( isinstance ( wilson [ 'money' ] , float ) ) #NEWLINE# self . assertTrue ( all ( [ isinstance ( self , float ) for m in wilson [ 'monies' ] ] ) )