Thank you James, for both the solution and the advice. I really liked forms_for_model as a crutch while I got up to speed on newforms, but like most crutches, I'm finding I may spend more time working against it. Still, a nifty thing for a simple, straightforward form.
On Jul 6, 3:12 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > EventFormClass.base_fields['club'].widget = > > widgets.Select(choices=Club.objects.filter(approved=True)) > > > But that throws > > TypeError at /clubs/events/ > > unpack non-sequence > > The 'choices' argument should look like this: > > ((1, 'Foo'), > (2, 'Bar'), > (3, 'Baz'), > (4, 'Quux')) > > Instead, it's going to look like this: > > [<Club object>, > <Club object>, > <Club object>, > <Club object>] > > So when the form goes to look "inside" each item to pull out the id > and string value of the choice, it finds that it can't -- it was > expecting a tuple or a list, and got a model instance instead. > > What you want is something like > > EventFormClass.base_fields['club'].widget = > widgets.Select(choices=[(club.id, str(club)) for club in > Club.objects.filter(approved=True)] > > Also, it's often a good idea to *not* try to shoehorn things into > form_form_model... usually it's quicker to write a custom form which > does what you want than to add/remove things from form_for_model. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---