Hello all,

I'm interested in finding-out the best practices for overriding the
form widgets styling by assigning appropriate CSS classes to them. In
particular, I'm trying to determine the best place (tm) to modify that
information when using the generic editing views
(CreateView/UpdateView).

Right now I do this by overriding the get_form in a CreateView (for
example), and having code along the lines of:

----%----
form = super(ProjectCreateView, self).get_form(form_class)
form.fields["name"].widget.attrs["class"] = "span6"
form.fields["description"].widget.attrs["class"] = "span6"

return form
----%----

Is this a good way to do it in order to reduce writing lots of
boilerplate, or should it be better to use a custom ModelForm +
FormView?

Best regards

-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

Attachment: signature.asc
Description: PGP signature

Reply via email to