[Answer]-Django model Foreignkey returning id and not the value as specified in __unicode__

1πŸ‘

βœ…

I think I understand your question. You seem to be expecting values_list to return the __unicode__ of a related model, but there’s no reason to think it would: as the name implies, it returns the values only, and the value of a ForeignKey field is just the ID.

You can supply a list of fieldnames to values_list and traverse the relationship there, if you want:

Expenditure.objects.values_list('description', 'amount', 'exp_type__ Expenditure_Type')

Leave a comment