Changes between Initial Version and Version 1 of Ticket #11846


Ignore:
Timestamp:
Sep 7, 2009, 8:37:08 AM (15 years ago)
Author:
Karen Tracey
Comment:

Fixed formatting. PLEASE use preview and follow the Wiki Formatting link to learn how to format things properly.

-0 is a valid decimal as far as Python is concerned:

Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> Decimal("-0")
Decimal("-0")
>>> x = Decimal("-0")
>>> y = Decimal("1")
>>> x*y
Decimal("-0")
>>> x+y
Decimal("1")
>>> y-x
Decimal("1")
>>> y+x
Decimal("1")
>>> 

It's going to behave just like 0 so there shouldn't be any problem with accepting it. Django is not going add additional requirement for "valid decimal" beyond what Python already imposes.

If you want to get rid of the negative sign for display purposes you can always just multiply zero-valued critical_nfr values with themselves to ensure they have positive sign. (If you are determined to reject such entries you can use the is_signed Decimal method to detect the situation: http://docs.python.org/library/decimal.html#decimal.Decimal.is_signed.)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11846

    • Property Resolutioninvalid
    • Property Status newclosed
  • Ticket #11846 – Description

    initial v1  
    11I am having a class which is defined as
    22
    3                        
     3{{{
     4#!python                       
    45class ABC(models.Model):
    56        id = models.CharField(max_length=100, primary_key=True)
     
    2122                return "/abc/%i/" % self.id
    2223
    23 
    24 
     24}}}
    2525
    2626And form.py looks like
    2727
    28 
     28{{{
     29#!python
    2930class SiteForm(ModelForm):
    3031        class Meta:
     
    5152                                        if rejection_code != None and new_rejection_reason!='':
    5253                                                raise forms.ValidationError('You cannot select both, either select a reason or write it !')
    53 
     54}}}
    5455
    5556
Back to Top