Re: A question about Model.full_clean

2012-06-01 Thread David Markey
In the actual code, I'm taking input from 3rd party code which could be None :( I think the best option is to override clean_fields* *to check for non-nullable fields that are null. * * * * On 1 June 2012 17:26, Alasdair Nicol wrote: > On 01/06/12 14:47, David Markey wrote: > > Hi All, > > S

Re: A question about Model.full_clean

2012-06-01 Thread Alasdair Nicol
On 01/06/12 14:47, David Markey 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

Re: A question about Model.full_clean

2012-06-01 Thread David Markey
Hmm.. In my opinion, Model.full_clean() should catch this particular error. On 1 June 2012 16:17, Kurtis Mullins wrote: > It looks like the CharField is accepting 'none' in its to_python method. > That might explain why we don't get the error until your to save it. I'm > sure there is a rea

Re: A question about Model.full_clean

2012-06-01 Thread Kurtis Mullins
It looks like the CharField is accepting 'none' in its to_python method. That might explain why we don't get the error until your to save it. I'm sure there is a reason behind this -- I just don't know what it is :) Source: django/db/models/fields/__init__.py On Fri, Jun 1, 2012 at 11:08 AM, Kurti

Re: A question about Model.full_clean

2012-06-01 Thread Kurtis Mullins
Yeah, I'm getting exactly the same results. It seems that it's not throwing the IntegrityError until you try to save it. I suppose that's because it's marked as 'not null' in the database. It appears to be ignoring it in the actual clean() (and consequently clean_fields()) methods. I'm going to loo

Re: A question about Model.full_clean

2012-06-01 Thread David Markey
1.4 On 1 June 2012 15:54, Kurtis Mullins wrote: > What version of Django are you using? > > > On Fri, Jun 1, 2012 at 10:47 AM, David Markey wrote: > >> That is my exact class for that model. >> >> >> On 1 June 2012 15:27, Kurtis Mullins wrote: >> >>> From the docs: >>> https://docs.djangoproje

Re: A question about Model.full_clean

2012-06-01 Thread Kurtis Mullins
What version of Django are you using? On Fri, Jun 1, 2012 at 10:47 AM, David Markey wrote: > That is my exact class for that model. > > > On 1 June 2012 15:27, Kurtis Mullins wrote: > >> From the docs: >> https://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#django.db.models.

Re: A question about Model.full_clean

2012-06-01 Thread David Markey
That is my exact class for that model. On 1 June 2012 15:27, Kurtis Mullins 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: > arti

Re: A question about Model.full_clean

2012-06-01 Thread Kurtis Mullins
>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_E

A question about Model.full_clean

2012-06-01 Thread David Markey
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]: t