django select max field from mysql when column is varchar
- by doza
Hi,
Using Django 1.1, I am trying to select the maximum value from a varchar column (in MySQL.) The data stored in the column looks like:
9001
9002
9017
9624
10104
11823
(In reality, the numbers are much bigger than this.)
This worked until the numbers incremented above 10000:
Feedback.objects.filter(est__pk=est_id).aggregate(sid=Max('sid'))
Now, that same line would return 9624 instead of 11823.
I'm able to run a query directly in the DB that gives me what I need, but I can't figure out the best way to do this in Django. The query would be:
select max(sid+0) from Feedback;
Any help would be much appreciated.
Thanks!