On Thu, Sep 22, 2011 at 2:19 AM, Jacob G <ja...@fareclock.com> wrote:
> I'm trying to customize Django forms html based on three requirements:
> 1) Html output to match html given to me by a web site designer.
> 2) Automatically generate forms, so I don't have to duplicate html in
> templates.
> 3) Re-use as match of Django forms code as possible.
> For my first attempt, I'm working on an authentication form. So here's what
> I did:
> 1) Derive AuthenticationForm class so that I can create use derived classes
> for the CharFields
> 2) Derive CharField to set css class in widget_attrs
> 3) Derived ErrorList to use own custom html for errors
> Another problem came up: Django assumes that field errors should be
> displayed before the field label. However, I want to display the field error
> after the field's input (after a line break). It would seem that I would
> have to override BaseForm method _html_output, which I would like to avoid.
> Summary Question: Is there a simpler way to output field error html after
> field, rather than before field, without having to override _html_output?
> Thanks.

Yes - use a template.

Django's forms library includes some rendering capability, but that's
for scaffolding purposes. The intention is not to provide a completely
customizable way to generate HTML in code.

If Django's default form output doesn't meet your needs, then the
solution isn't to try and modify the code -- it's to modify the output
at the template level.

https://docs.djangoproject.com/en/1.3/topics/forms/#customizing-the-form-template

Yours,
Russ Magee %-)

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to