On 7 jan, 11:38, phoebebright <[email protected]> wrote:
> Finally got it working - and I'm sure there is a much clear way of
> doing it...
>
> used_fuels= Car.objects.all().values('fuel_type').distinct()
> fuel_choices=[('Any','Any Fuel')]
> for f in used_fuels:
> for key,value in f.items():
> fuel_choices.append((value,value))
> fuels = forms.ChoiceField(choices=fuel_choices)
used_fuels = Car.objects.values_list('fuel_type', flat=True).distinct
()
fuel_choices = [('Any', 'Any Fuel')] + [(item, item) for item in
used_fuels]
fuels = forms.ChoiceField(choices=fuel_choices)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---