Django many to many queries
- by Hulk
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