Jim
unread,Sep 22, 2009, 3:59:25 PM9/22/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello,
I have a widget that makes suckerfish menus (the kind of menu that is
written in css and where if you hover your mouse over a menu item any
subitems appear).
I have some data that can be displayed according to three dimensions.
(For instance, I could characterize contributers by gender, by
political persuasion, and by nationality.) I want to get the tree of
choices out of the database and to the widget, by dimension.
Thus, if the url is contributer/gender then the choices might be
[ ('male', ['male'] ), ('female', ['female']) ]
while if the url is contributer/politics then the choices given to the
widget might be this.
[ ('democrat', ['democrat']), ('republican', ['republican']),
('looney', ['looney']),
('looney > right wing', ['looney','right wing']), ('looney >
left wing', ['looney','left wing'])]
(I could show the widget if folks thought it would be helpful.)
I have this form and field.
class CharacterizationForm(forms.Form):
def __init__(self,*args,**keywords):
if dimen in keywords: # make any sense?
self.dimen=dimen
super(CharacterizationForm,self).__init__(*args,**keywords)
pick=CharacterizationField
(required=True,widget=widgets.CharacterizationWidget)
class CharacterizationField(forms.ChoiceField):
--some stuff--
super(CharacterizationField, self).__init__(choices=choices,
required=required, widget=widget, label=label, initial=initial)
self.widget.choices=self.choices
Of course, in the view I initialize the form in some way.
f=MenuForm(initial={'dimen',dimen})
came to mind, although perhaps that is not right? Now, how do I get
the information about the dimen into the "--some stuff--", where I can
then set up the choices from it?
I have been looking at the forms and fields, but I admit I'm not
getting it. Any help greatly appreciated.
Jim