On Sep 22, 10:58 pm, BobZ <[EMAIL PROTECTED]> wrote: > Thanks dmorozov, that worked fine in the sense that it returned only > unique years in a select box, but it still didn't order them properly > (getting non-duplicate years as 1961, 1931, 2000, 1975, 1995, etc.). > > Somehow the order_by section of "set([(obj.year, obj.year) for obj in > Vehicle.objects.all().order_by('-year')]) " isn't performing its > function. > > Any ideas? > > Thanks again! >
To be honest, dmorozov's solution sounds like overkill for what you need. Try something like this: class SearchForm(forms.ModelForm): year = forms.ModelChoiceField(queryset=Vehicle.objects.order_by('- year').distinct()) You'll need to be sure Vehicle has a __unicode__ method for this to work. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---