Hi all,
the newforms library looks very useful to me, but today I encountered a
quite annoying issue.
I usually have my validators in the model (e.g.
django.core.validators.RequiredIfOtherFieldNotGiven appended to a
field's validator_list), but this is not honored by the newforms library
when I create a form based on the model.
Example:
## in models.py
class Feedback(models.Model):
phone = models.CharField(maxlength=64, blank=True,
validator_list=[RequiredIfOtherFieldNotGiven('email'),] )
email = models.EmailField(blank=True,
validator_list=[RequiredIfOtherFieldNotGiven('phone'),] )
notes = models.TextField(blank=True)
## and in my view I have something like:
fbform = newforms.models.form_for_model(Feedback)
form = fbform({'notes':'xyz'})
form.is_valid() ### this returns True, and form.errors is empty.
For simpler validators, e.g. too long phone number, form.is_valid()
returns False which is as expected.
Any thoughts what I am doing wrong here, or is this just a bug which I
should report to the bugtracker?
By the way, creating all fields in a form class again just does not seem
right to me (DRY), so I chose to use "form_for_model".
br,
Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---