1.4 On 1 June 2012 15:54, Kurtis Mullins <[email protected]> wrote:
> What version of Django are you using? > > > On Fri, Jun 1, 2012 at 10:47 AM, David Markey <[email protected]> wrote: > >> That is my exact class for that model. >> >> >> On 1 June 2012 15:27, Kurtis Mullins <[email protected]> wrote: >> >>> From the docs: >>> https://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#django.db.models.Model.full_clean >>> >>> from django.core.exceptions import ValidationError, NON_FIELD_ERRORStry: >>> 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 <[email protected]> wrote: >>> >>>> Hi All, >>>> >>>> Say I have this model >>>> >>>> class TestModel(models.Model): >>>> my_test = models.CharField(max_length=512, blank=True) >>>> >>>> And I try this: >>>> >>>> In [1]: from core.base.models import TestModel >>>> >>>> In [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 =* None* >>>> >>>> In [8]: test_model2.full_clean() >>>> >>>> In [9]: test_model2.save() >>>> >>>> ##*IntegrityError raised* >>>> >>>> Is 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="". >>>> >>>> >>>> Thanks >>>> >>>> David >>>> >>>> -- >>>> 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. >>>> >>> >>> -- >>> 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. >>> >> >> -- >> 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. >> > > -- > 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. > -- 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.

