I have a model that has a car and a car has a foreign key to carmodel
via the field model (too many models!)
This is the line for the form which appears to run:
carmodel=forms.ModelChoiceField(queryset=Car.objects.all().values
('model','model__name').distinct() )
It generates the correct SQL
SELECT DISTINCT `carpoint_car`.`model_id`, `carpoint_carmodel`.`name`
FROM `carpoint_car` INNER JOIN `carpoint_carmodel` ON
(`carpoint_car`.`model_id` = `carpoint_carmodel`.`id`)
and if I run this manually I get 6 records returned:
6 Galaxy
7 Bigun
8 Touring
9 Espace
10 D1
11 Tank
But I don't get the form being displayed. If I remove this line the
form displays okay.
What pattern is ModelChoiceField expecting in the queryset to know
what fields to use to generate a choice from?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---