1

I want to use tmp_id as a value of row id in extra method .

code:

order_obj = table.objects.filter()
.annotate(
     tmp_id=F('table2__test_data')
)
.extra(
      select={"val":"select id from data where row_id = {{here i want to use 
      tmp_id}} limit 1"}
)

can anyone tell me how to do it ?

sachin dubey
  • 755
  • 9
  • 28
  • Can you explain more about your question? – Hamidreza Oct 19 '19 at 11:30
  • i want to use tmp_id of .annotate in .extra ....i.e every row contains different tmp_id and i want to pass that tmp_id to .extra function and get some diffrent value . @HamidrezaAhmadi – sachin dubey Oct 19 '19 at 12:21

1 Answers1

0

I could not find any solution where we can use temp_id directly but there is an alternative where i can directly specify table2.test_data in extra method given below .

order_obj = table.objects.filter()
.annotate(
     tmp_id=F('table2__test_data')
)
.extra(
      select={"val":"select id from data where row_id = table2.test_data limit 1"}
)
sachin dubey
  • 755
  • 9
  • 28