Re: ModelChoiceField with Unique Results

2008-09-24 Thread BobZ
Wow, thank you so much Daniel. I totally get this now, and it works! Looks like I've sort of been skirting around this solution for a while but, being clueless as I can be sometimes with Django, I never knew what I could've been doing wrong. Thanks a lot for the help again. -Bob On Sep 23, 4:

Re: ModelChoiceField with Unique Results

2008-09-23 Thread Daniel Roseman
On Sep 23, 4:44 pm, BobZ <[EMAIL PROTECTED]> wrote: > Thanks Daniel.  I've found solutions similar to yours in other threads > on the net, and everytime I test them, I literally get no form at all > in my rendered template. > My template appears to have all the correct code in it as you can see >

Re: ModelChoiceField with Unique Results

2008-09-23 Thread BobZ
I had SOME luck with "queryset=Vehicle.objects.filter(year=True)" in that the form actually rendered in my template, but the year select box is empty now. All other select boxes load fine (Make and Model) with their data...only year still won't work. On Sep 23, 10:44 am, BobZ <[EMAIL PROTECTED]>

Re: ModelChoiceField with Unique Results

2008-09-23 Thread BobZ
Thanks Daniel. I've found solutions similar to yours in other threads on the net, and everytime I test them, I literally get no form at all in my rendered template. My template appears to have all the correct code in it as you can see in the link "search.html" at the bottom of this post. Looking

Re: ModelChoiceField with Unique Results

2008-09-22 Thread Daniel Roseman
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 sectio

Re: ModelChoiceField with Unique Results

2008-09-22 Thread BobZ
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.al

Re: ModelChoiceField with Unique Results

2008-09-22 Thread [EMAIL PROTECTED]
You can try something like this: class SearchForm(forms.ModelForm): year = forms.ChoiceField() def __init__(self, *args, **kwargs): super(SearchForm, self) .__init__(*args, **kwargs) self.fields['year'].choices = \ set([(obj.year, obj.year) for obj in \

Re: ModelChoiceField with Unique Results

2008-09-22 Thread [EMAIL PROTECTED]
You can try something like this: class SearchForm(forms.ModelForm): year = forms.ChoiceField() def __init__(self, *args, **kwargs): super(SearchForm, self) .__init__(*args, **kwargs) self.fields['year'].choices = \ set([(obj.year, obj.year) for obj in \