Django many to many queries

Posted by Hulk on Stack Overflow See other posts from Stack Overflow or by Hulk
Published on 2010-04-13T08:51:43Z Indexed on 2010/04/13 8:52 UTC
Read the original article Hit count: 564

In the following,

How to get designation when querying Emp

     sc=Emp.objects.filter(pk=profile.emp.id)[0]
     sc.desg //this gives an error


 class Emp(models.Model):
   name = models.CharField(max_length=255, unique=True)
   address1 = models.CharField(max_length=255)

   city = models.CharField(max_length=48)
   state = models.CharField(max_length=48)
   country = models.CharField(max_length=48)
   desg = models.ManyToManyField(Designation)

class Designation(models.Model):
  description = models.TextField()
  title = models.TextField()
  def __unicode__(self):
    return self.board

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models