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.

How can I validate a new child object based on its parent information?
I'm surprised not finding any information regarding this issue :)



Thanks!

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BDCN_tcJgmi1tZGTROPkqF0rAtEcx-gRtRnBFrVWE_v%2Bp-wLg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to