Opened 13 years ago

Last modified 13 years ago

#17774 closed Bug

In BooleanField default value is not set — at Initial Version

Reported by: ptrans_pp@… Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal 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

My code:


class Employee(models.Model):

class Meta:

verbose_name = _('Employee')
verbose_name_plural = _('Employees')

is_active = models.BooleanField(default=True, name=_('Active'), verbose_name=_('Active'))

class EmployeeForm(forms.ModelForm):

class Meta:

model = Employee

def create(self, request, *args, kwargs):

form = EmployeeForm()

if form.is_valid():

try:

print "Form clean data is %s" % form.cleaned_data
return form.save()

except PermissionDenied:

return rc.FORBIDDEN

except Exception:

return rc.INTERNAL_ERROR

else:

print form.errors.as_text()


Output is:

Form clean data is {'is_active': False}

Change History (0)

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