from django.core.exceptions import ValidationError, NON_FIELD_ERRORS try: article.full_clean() except ValidationError as e: non_field_errors = e.message_dict[NON_FIELD_ERRORS]It looks like it's not firing off that exception in your case -- unless it's being supressed somehow. Did you override anything else in that Model? Or is this example literally 'it'?
On Fri, Jun 1, 2012 at 9:47 AM, David Markey <admin@dmarkey.com> wrote:
Hi All,Say I have this modelclass TestModel(models.Model):my_test = models.CharField(max_length=512, blank=True)And I try this:In [1]: from core.base.models import TestModelIn [2]: test_model = TestModel()In [3]: test_model.my_test = ""In [4]: test_model.full_clean()In [5]: test_model.save()
Ok cool, this is expected.How about:In [6]: test_model2 = TestModel()In [7]: test_model2.my_test = NoneIn [8]: test_model2.full_clean()In [9]: test_model2.save()##IntegrityError raisedIs there a way for full_clean() to catch that the "my_test" field is Null when it shouldn't be, when blank=True?If I have blank=False, it wont validate when my_test="".ThanksDavid--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment