This function can transform a list of Model objects into a list suitable
for use as a choices list in fields and widgets.
traceback.print_exc()
raise e
return show
+
+def make_choices(objects):
+ """
+ Transforms a list (or iteratable) of model objects to a list
+ suitable to be used as a list of choices in form widgets like
+ Select.
+
+ This fullfills a similar (but simpler) function as
+ django.forms.models.ModelChoiceIterator, but that one requires a
+ FormField and is not public.
+ """
+ return [(o.pk, o) for o in objects]