On Wed, Oct 16, 2013 at 11:52 PM, Marc Aymerich <
glic...@gmail.com> wrote:
> Yep,
> I'm writing some validation logic for a model that is being used in an
> admin inline form
>
> The model looks like this
>
> class Child(models.Model):
> parent = models.ForeignKey(Parent)
>
> def clean(self):
> super(....).clean()
> if self.parent.surname != self.surname:
> raise ValidationError....
>
> The problem is that on the "Parent add admin view" I get a
> Parent.DoesNotExist error when I'm saving new Parent and Childs. That
> is because when child.clean() is called child.parent_id is None, so
> self.parent fails, it looks like self.parent is created afterwards and
> is not available at that time.