Does anyone know how to get a distinct value in Django QuerySet? I'm using MySQL db and I couldn't find a solution yet.
The table is:
ID WORK_YMD LINE_NM MODEL_CODE MAG_NO PRODC_MAGT_NO
118002 20191015 PBA-21F BN94-14806W A656MAF00001 BR10BN9414806WA656MAE4035
118003 20191015 PBA-21F BN94-14806W A656MAF00001 BR10BN9414806WA656MAE4027
118004 20191015 PBA-21F BN94-14806W A656MAF00001 BR10BN9414806WA656MAE4039
118005 20191015 PBA-21F BN94-14806W A656MAF00001 BR10BN9414806WA656MAE4037
118006 20191015 PBA-21F BN94-14806W A656MAF00001 BR10BN9414806WA656MAE4038
I want to get the model_code considering a Filter mag_no = "My Variable" Ex:A656MAF00001
I tried something like this, but didn't work.
Magazine.objects.filter(mag_no='A656MAF00001').get('model_code').distinct().order_by()
The error is:
"Too many values to unpack"