vpetkov
unread,Aug 23, 2011, 9:30:03 AM8/23/11Sign 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
Hi,
I have run into a problem that doesn't seem to have a trivial
solution in Django: I would like to have a form field that contains
parts of the html output so that it is not rendered directly by
Widget.render(), but in the template itself.
On a more concrete basis, let there be a forms.Form with a
MultipleChoiceField form field whose widget produces a collection of
checkboxes. I could simply override the CheckboxSelectMultiple's
render() function in order to group them in various ways, but I am
aiming for a more flexible approach. Suppose that I have already
overridden the render() function so that it produces a dictionary
containing the html code for each checkbox separately. What I would
like to have in the template is:
{{ form.tueren.A}}
{{ form.tueren.B }},
etc.
Now, adding attributes/methods to the MultipleChoiceField instance is
easy, but since what the template sees is a BoundField() instance, I
have no way to access my additional attributes. Did anybody encounter
this problem already and how can it be solved in an elegant way?
Best regards,
Venelin Petkov