[Answer]-Reverse relation ship is not working in django models?

0👍

i tried this one as said by @Rohan. its working fine

parts_list = tbmstpart.objects.filter(tbtrnappraisalquestion_intPartID__intTemplateID__exact=4).distinct()

1👍

You have typo of __ in tbtrnappraisalquestion__intTemplateID rather you want tbtrnappraisalquestion_intTemplateID, with single underscore.

Change your query to

Assuming your tbmsttemplate model has intTemplateID as int primary key,

parts_list = tbmstpart.objects.filter(tbtrnappraisalquestion_intPartID__intTemplateID__intTemplateID__exact=4)
#there is no typo here, you have to do __intTemplateID__intTemplateID as your pk field in `tbmsttemplate` and FK `tbtrnappraisalquestion`  are same
👤Rohan

Leave a comment