#11846: field check does not wok
-------------------+--------------------------------------------------------
 Reporter:  ankit  |       Owner:  nobody    
   Status:  new    |   Milestone:            
Component:  Forms  |     Version:  1.1-beta-1
 Keywords:         |       Stage:  Unreviewed
Has_patch:  0      |  
-------------------+--------------------------------------------------------
 I am having a class which is defined as


 class ABC(models.Model):
         id = models.CharField(max_length=100, primary_key=True)
         pub = models.ForeignKey(WapUser, null=True)
         brief_description = models.TextField(null=True,blank=True)
         status = models.CharField(max_length=12, null=True,
 help_text='Select the appropriate status and click on save',
 choices=SITE_STATUS_CHOICES )
         created_on = models.DateTimeField(null=True)
         pub_share =
 models.DecimalField('site_rev_share',max_digits=4,decimal_places=2,null=True)
         require_full_size_banner = models.IntegerField("Full Size Banner
 Ads", choices=BOOLEAN_CHOICES, default = 0,null=True)
         modified_on =
 models.DateTimeField(auto_now=True,auto_now_add=True,verbose_name
 ='Last_modified_on')
         critical_nfr =
 
models.DecimalField(max_digits=5,decimal_places=3,default='60',help_text='Plesae
 Enter in the range of (0-100)')
         class Meta:
                 db_table = u'wap_abc'
                 verbose_name_plural= "ABC"
                 managed = False
         def __unicode__(self):
                 return self.status
         def get_absolute_url(self):
                 return "/abc/%i/" % self.id




 And form.py looks like


 class SiteForm(ModelForm):
         class Meta:
                 model = ABC
         reason_for_reject =
 CharField(widget=forms.Textarea,max_length=500,help_text='Please enter if
 the reason is not in the list',required=False)


      def clean(self):
                 cleaned_data = self.cleaned_data
                 newStatus = self.cleaned_data.get('status')
                 id_a = self.cleaned_data.get('id')
                 critical_nfr = self.cleaned_data.get('critical_nfr')

                 if new_pub_share == 0 or new_pub_share >=100:
                         raise forms.ValidationError('You cannot set
 pub_share either equal to 0% or greater than equal to 100% !')
                 if critical_nfr <0  and critical_nfr is not None:
                         raise forms.ValidationError('You cannot set
 critical_nfr less than Zero !')
                 if self.instance and self.instance.status=='pending':
                         if newStatus =='activated' or newStatus ==
 'rejected':

                                 if newStatus == 'rejected':
                                         if rejection_code is None and
 new_rejection_reason=='':
                                                 raise
 forms.ValidationError('Please select a reason to reject or else write in
 the box given below  !')
                                         if rejection_code != None and
 new_rejection_reason!='':
                                                 raise
 forms.ValidationError('You cannot select both, either select a reason or
 write it !')



 now if i enter the value of critical_nfr<0,it gives error but if i give
 '-0' then it does not give any error.WHy .-0 is not any number

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11846>
Django <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to