Hi!
So i'm trying to validate the creation of a new object from input
data, but not going through forms, as this is a json webservice. For
various reasons, by the time the "constructor" code is reached, the
data is already deserialized, and to use django forms (and hence its
validation mecanism), i'd have to re-stringify everything, which
doesn't make sense.
So i just create a new object, like f=Foo(), and fill in the fields
based on which ones were present in the input data.
Then i call f.validate().
The problem is that for IntegerField's with a default of 0, validate()
calls the field's validate_full, which does this:
if not self.blank and not field_data:
return [_('This field is required.')]
Well, that fails... because 0 is not True. But the field *does* have a
value!!! it should validate!
Furthermore, even if i were to set it to 0, it'll still not validate!
There's no validator that says it's not zero or anything, the field is
just a plain integerfield:
position_x = models.IntegerField(default=0)
Isn't this a bug? Shouldn't django do something like:
if not self.blank and field_data is not None and field_data !=
'':
return [_('This field is required.')]
???
Of course, i could set my field to say blank=True, but that's a bit
counterintuitive, i think.
thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---