I have been trying to search forums to get an answer for this, but it seems like its a bit tricky to search.
I have the following model which is pulling users from django User table:
class trendingidea(models.Model):
iname = models.CharField(unique=True, max_length=15)
idea = models.TextField(unique=True)
submittedon = models.DateTimeField()
support = models.PositiveSmallIntegerField()
readbyadmin = models.BooleanField()
feasibilitycheck = models.BooleanField()
submittedby = models.ForeignKey(User,related_name="submitted_by")
assignedto = models.ForeignKey(User, blank=True, null=True, related_name="assignedto")
However when i query the database and pull the information:
ti=list(trendingidea.objects.values())
print(ti)
[{'readbyadmin': False, 'id': 1, 'idea': 'cisco', 'feasibilitycheck': True, 'submittedby_id': 1, 'support': 1, 'submittedon': datetime.datetime(2017, 11, 6, 11, 8, 10, tzinfo=<UTC>), 'iname': 'cisoc', 'assignedto_id': 1}]
in place of submittedby and assignedto it gives me submittedby_id: 1 and assignedto_id: 1.
I wanted the usernames and not their IDs. is there a way to achieve this?