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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---