I have three models in Django, One is default django user model.
class ConfigurationDB(models.Model):
project_id = models.CharField(max_length=250)
def __unicode__(self):
return str(self.project_id)
class ProjectAssociated(models.Model):
user_name = models.ForeignKey(User, verbose_name="User Name")
configuration = models.ManyToManyField(ConfigurationDB, verbose_name= "Project Associated")
def __unicode__(self):
return str(self.user_name)
I got username from the url, I want to write a Django Query to get the project Associted with that user, and store in a list.
User.objects.get(username="ashish")and got the list byassociated_project_list = user1.associated_projects.all(), But still I got [<AssociatedProject: ashish>] , but what I need is the project_Id which is a character , I have tried loop also , but still doesn't get the desire result.