On Wed, 2008-11-26 at 12:19 -0800, ChrisK wrote:
> Sorry, I cut down my example poorly.
>
> template has
>
> <form action="/map/fences/newFence/" method="POST">
> {{form.teaser.field.initial}}
> {{form.auth_id}} {{form.fence_id}}
> <p><label for="id_teaser">Reminder String:</label>
> <input id="id_teaser" type="text" name="teaser" maxlength="40" /
> ></
> p>
The answer to your question as to whether this is correct syntax is
"yes, it is". However, I guess from the fact that you asked the
question, that what you're really asking is how to get the initial value
that the form will assign to the field. Since initial data can come from
either the form or the field, the way you are accessing it above is too
specific (in this case, the field class itself doesn't have initial
data, but the form might well have some initial data for that field).
If you look in django/forms/forms.py in the BoundField.as_widget()
method, you'll see how Django works out the value for a form widget.
It's a combination of the forms "data" value for the field, form initial
data and field initial data. Which also hints that it's almost never
going to be correct to force the use of "initial" data at the template
level, since if there's form-supplied "data" data, that should override
the "initial" data value. At the template level, attemptign to
differentiate between a value that was an initial default and a value
that was supplied by a previous post to the form is not really
appropriate. Even if you could do so, it would be exploiting a leaky
abstraction. At the form display level, you simply shouldn't care about
that difference.
Again, it comes to down to "what is the real problem you are trying to
solve?"
At the templ
Regards,
Malcolm