Django foreign key question

Posted by Hulk on Stack Overflow See other posts from Stack Overflow or by Hulk
Published on 2010-03-27T10:19:12Z Indexed on 2010/03/27 10:23 UTC
Read the original article Hit count: 503

All,

i have the following model defined,

  class header(models.Model):
     title = models.CharField(max_length = 255)
     created_by = models.CharField(max_length = 255)

     def __unicode__(self):
       return self.id()

 class criteria(models.Model):
     details =   models.CharField(max_length = 255)
     headerid = models.ForeignKey(header)

     def __unicode__(self):
       return self.id()

 class options(models.Model):
     opt_details =   models.CharField(max_length = 255)
     headerid = models.ForeignKey(header)

     def __unicode__(self):
       return self.id()

AND IN MY VIEWS I HAVE

           p= header(title=name,created_by=id)
           p.save()

Now the data will be saved to header table .My question is that for this id generated in header table how will save the data to criteria and options table..Please let me know..

Thanks..

© Stack Overflow or respective owner

Related posts about django

Related posts about django-views