On 05/14/2011 05:33 PM, Greg Donald wrote:
On Sat, May 14, 2011 at 4:22 PM, Daniel Roseman<dan...@roseman.org.uk>  wrote:
Which is what Shawn said. If you follow the pattern described in the
excellent documentation, you'll see that there's no reason to try and
reference the form's data, as the form will re-render itself anyway if
validation fails. And there's no reason to have separate templates or views
for add and edit.
So the fact that form.name.data is set sometimes but not others is not
a bug?  Seems like a bug to me.  Why is it set at all if accessing it
isn't the preferred way?

So OK, if I do use {{ form.name }} then I have to set CSS attributes
for every field using:

name = forms.CharField( widget=forms.TextInput(attrs={'class':'special'}))

How is that better than just writing a simple<input>  field myself?


There are a lot of benefits, beginning with the fact that doing it once in your Form class is a lot better than doing it in each template.

Secondly, if you ever use a prefix with your form or use a formset, then writing your own raw HTML elements is going to bite you hard.

I'm certain there are plenty of reasons that others could chime in with. In any case, you're free to do it however you like. But if you choose to use Django, be aware of the fact that a huge amount of thought has gone into the project, and if something's there it's probably for a really good reason. When you choose not to follow a Django convention and run into a problem then don't be surprised.

Shawn


--
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