Opened 15 years ago

Last modified 15 years ago

#11846 closed

field check does not wok — at Initial Version

Reported by: ankit Owned by: nobody
Component: Forms Version: 1.1-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (0)

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