model object query

2 views
Skip to first unread message

Dev Gis

unread,
Sep 4, 2019, 10:26:39 PM9/4/19
to Django users

Hi All,

How to get the ForeignKey value while querying the model object.


I was trying to query a model object "mla" to fetch a specific sets of columns and its working fine but the field ForeignKey "instuid" returning a numeric value instant of actual associated value.

Do I need to edit the query in views.py

def mlas_datasets(request):
 mlaAll = list(mla.objects.values('mla_name_short','mla_name_full','inst_acronym','mla_type','year_adopted','instuid','mla_uid'))
mlaAll = JsonResponse(mlaAll,safe=False)
return HttpResponse(mlaAll,content_type='json')

Regards
Deb
Reply all
Reply to author
Forward
0 new messages