Thursday, February 3, 2011

Re: Possible bug in model validation

Las try or I will report it as a bug as I think it is.

2011/1/28 Miguel Araujo <muchochini@gmail.com>
Well,

I'm just trying to figure out if this should be reported. 

Thanks, regards

----
Miguel Araujo
@maraujop

2011/1/22 Miguel Araujo <muchochini@gmail.com>

Hi everyone,

I have a model A that has a overwritten save method that updates a model B's field. Both (A & B) have model validation using full_clean method. Problem is that B model's validation fails when updating the field, because it raises an IntegrityError saying the primary key already exits, obviously. 

To fix this within my save method I have done:

        if kwargs.get('force_update') is False:
            self.full_clean()

If this is the desired behavior, then just let me know, I don't think the primary key on an update should be validated this way. 

Thanks, best regards

----
Miguel Araujo
@maraujop


--
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