Recently started using Django ORM.I want to execute this query
select student_id from students where student_id like "%97318%" order by CAST(student_id as UNSIGNED) desc;
where student_id is a CharField which I want as integer for querying.
I tried with
students.objects.filter(student_id__contains "97318").order('-student_id')
works fine. But don't know and couldn't find how to cast "student_id" to int like the actual MySQL query mentioned above with "Django ORM". should I use raw query or is there a way out?
Let me know your suggestions.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…