On Jan 1, 7:00 am, Steven Arnold <[email protected]> wrote:
> Hi, my problem is that the "initial" parameter in forms.Form seems to
> have no effect.  I set the "subject" value in this code:
>
>         form = ContactForm(
>             initial={'subject': 'I love your site!'}
>         )
>
> ...yet this initialization string never makes it to the HTML as the
> default value for the "subject" input field.  My question is, why
> not?  What am I doing wrong?
>
<snip>
>
>     <form action="/contact/" method="post">
>         <p>Subject: <input type="text" name="subject"></p>
>         <p>Your email (optional): <input type="text" name="e-mail""></
> p>
>         <p>Message: <textarea name="message" rows="10" cols="50"></
> textarea></p>
>         <input type="submit" value="Submit">
>     </form>

.... er, you're not using Django to create the form HTML here. How are
you expecting the values to be inserted?

You need to use the template variables:
<p>Subject: {{ form.subject }}</p>
etc.

BTW it's good practice to use HTML label tags too: <label
for="id_subject">Subject</label> - these help with accessibility and
styling.
--
DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to