Modify Django Forms

Posted by Ninefingers on Stack Overflow See other posts from Stack Overflow or by Ninefingers
Published on 2010-06-15T19:28:09Z Indexed on 2010/06/15 19:32 UTC
Read the original article Hit count: 487

Filed under:
|
|

Hi All,

I've recently been developing on the django platform and have stumbled upon Django Forms (forms.Form/forms.ModelForm) as ways of creating <form> html.

Now, this is brilliant for quick stuff but what I'm trying to do is a little bit more complicated. Consider a DateField - my current form has fields for day, month and year and constructs a python date object from that. However, a django form creates a single textbox in which the correct format (say 2010-06-15) must be entered. As another example, for large fields I need to replace <input> with <textarea>.

I'd like to take advantage of Django's forms for simple validation but I need something simpler for my users. So my question is: can I intercept the rendering of one of these objects to write out the html as I like? If so, do I have to do all the writing myself or can I only do those objects I wish to re-write?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about python

Related posts about django