Given the corresponding query and output, what would be the best way to 
translate that into Django?  I've looked at QuerySet, filter, etc. but 
can't quite figure out the best way to do this.  The idea is to find the 
nearest 20 rows that matches, of course.

The 20000 will be passed via URL (i.e. http://mydomain.com/salary/20000) 
to my view, which normally looks something like this using generic views.

def by_pay(request, query_id):
        qs = positions.objects.filter(position_payrate=query_id)
        return object_list(request, qs)

and urls.py looks something like this:

        (r'^salary/(?P<query_id>\d+)/$', 'pay.views.by_pay'),

I would want to sort the final output by I think a Django filter in the 
template will be fine for this purpose.

Thanks!!

Tim

sqlite> select position_payrate, position_payrate - 20000 as diff, 
abs(position_payrate - 20000) as adiff from positions order by adiff asc 
limit 20;
20000|0|0
20000|0|0
19668.74|-331.26|331.26
19392|-608|608
20758|758|758
19200|-800|800
19200|-800|800
20800|800|800
20800|800|800
19095|-905|905
20988|988|988
21000|1000|1000
19000|-1000|1000
19000|-1000|1000
21000|1000|1000
21071|1071|1071
18720|-1280|1280
21300|1300|1300
21308|1308|1308
21320|1320|1320

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to