I'm new to Django, and making good progress rewriting a Struts-based
website. (It started rotting because I found Struts so painful and
non-intuitive. Django is so much easier.)
The major problems I'm running into have to do with HTML generation,
first with error messages, and then with RadioSelect. In general, I
don't like the, default, as_p or as_ul options. I'm also finding that
the documentation on how to change the HTML is kind of thin, so I'm
reading code and guessing. For errors, I ended up doing something
like this:
form.errors # Force creation of _errors
errors = form._errors.items()
I now have a list of unformatted items which I can format anyway I want.
I'm running into a similar problem with RadioSelect. I found
widgets.RadioFieldRender, but I can't extend it (it isn't exported).
So I have a question and a suggestion.
Question: How do I control HTML generation, ideally at field- or
widget-level? I feel I must be overlooking something easy.
Suggestion: Instead of hardwiring formatting into Django, allow
attributes to specify formatting. E.g., here is the minimal HTML for
radio buttons for selecting gender:
<input type="radio" name="gender" value="m">Male
<input type="radio" name="gender" value="f">Female
I might want to generate some HTML before the first input, after the
last, and between adjacent inputs. RadioFieldRenderer does this in a
hardcoded way. How about providing, through the API, widget
attributes such as 'before', 'after', and 'in_between'? These could
default to what RadioFieldRendered does, but I could also substitute
my own.
Jack Orenstein
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---