On Mon, 2007-11-05 at 00:28 -0800, [EMAIL PROTECTED] wrote: > i have a queryset with 100 recoders, there are 20 recoders with > "stick=True". > so i want to display these 20 recoder first,then display other 80 > recordes. my question is: > > 1. i can write to for loop in templates, so display 20 first, then > display 80 with if clause. > 2. i get 2 queryset in view.py, one for 20 recoders, the other for 80 > recoders, then display separtely in templates file. > > which is better so performance?
It will very much depend on how long it takes to construct the queyrsets. There is no substitute for timing it. The only word of caution I always have in these situations is to bear in mind that both solutions might very well be "fast enough". Sometimes you don't need as fast as possible, only fast enough. If I had to guess, I would say the first option will be faster, but probably slower than the idea mentioned below. But years of experience have taught me not to trust my guesses. > do you have other suggestion for displaying such recoders? Can you put order the queryset? Remember that you can sort by booleans, so you can attach .order_by('stick') to your queryset? One thing to watch out for: I can't remember if boolean ordering is consistent across all databases or not: that is, you might have to experiment to see whether your database sorts True before False, or vice verse (if False sorts before True, then order_by('-stick') will work). Regards, Malcolm -- I don't have a solution, but I admire your problem. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---