0

In reference to this for mysql ,I tried the following in my Django code

myQuery.order_by('myColumn+0')


myQuery.order_by('myColumn'+0)

but none worked for me

Community
  • 1
  • 1
Deepanshu Goyal
  • 2,738
  • 3
  • 34
  • 61

1 Answers1

0

Well found the solution thanks to ppeterka 66

myQuery.filter().extra(
    select={'myinteger': 'CAST(mycharfield AS UNSIGNED)'}
).order_by('myinteger')

I used UNSIGNED instead of INTEGER, I guess my mysql doesnot support it

Deepanshu Goyal
  • 2,738
  • 3
  • 34
  • 61