@any_form_field.register(forms.DecimalField)<EOL>def decimal_field_data(field, **kwargs):
min_value = <NUM_LIT:0><EOL>max_value = <NUM_LIT:10><EOL>from django.core.validators import MinValueValidator, MaxValueValidator <EOL>for elem in field.validators:<EOL><INDENT>if isinstance(elem, MinValueValidator):<EOL><INDENT>min_value = elem.limit_value<EOL><DEDENT>if isinstance(elem, MaxValueValidator):<EOL><INDENT>max_value = elem.limit_value<EOL><DEDENT><DEDENT>if (field.max_digits and field.decimal_places):<EOL><INDENT>from decimal import Decimal<EOL>max_value = min(max_value,<EOL>Decimal('<STR_LIT>' % ('<STR_LIT>'*(field.max_digits-field.decimal_places),<EOL>'<STR_LIT>'*field.decimal_places)))<EOL><DEDENT>min_value = kwargs.get('<STR_LIT>') or min_value<EOL>max_value = kwargs.get('<STR_LIT>') or max_value<EOL>return str(xunit.any_decimal(min_value=min_value,<EOL>max_value=max_value,<EOL>decimal_places = field.decimal_places or <NUM_LIT:2>))<EOL>
Return random value for DecimalField

>>> result = any_form_field(forms.DecimalField(max_value=100, min_value=11, max_digits=4, decimal_places = 2))
>>> type(result)
<type 'str'>
>>> from decimal import Decimal
>>> Decimal(result) >= 11, Decimal(result) <= Decimal('99.99')
(True, True)