On Tue, 2008-11-25 at 18:03 -0800, ChrisK wrote:
> OK, thanks for your suggestions (and yes, I meant "POST").
> 
> The problem now appears to be how I initialize the form's value of
> auth_id! 

Oh, right. I missed that error initially. Yes, you're doing it
incorrectly. The first positional argument to a form (which is what you
are passing in) is the data from the form submission. Passing in that
data means the form is treated as a "bound" form, so the data is
validated as part of displaying the form, so that errors can be
displayed. Since you only passed in one of the many required values, you
get all those errors.

What you really want to pass in is initial data. This is done with the
"initial" parameter to the form constructor. So your GET branch would
look like

        form = newFenceForm(initial={'auth_id' : auth_id})

I thought "initial" was documented in the forms documentation, but I
cannot find it right now, so maybe that's been missed. In any case,
that's the way to do it.
        
Regards,
Malcolm

> If I use just
> 
> {{form.as_p}}
> 
> in my template, I get the following html:
> 
> <ul class="errorlist"><li>(Hidden field auth_id) This field is
> required.</li></ul>
> <ul class="errorlist"><li>This field is required.</li></ul>
> <p><label for="id_teaser">Teaser:</label> <input id="id_teaser"
> type="text" name="teaser" maxlength="40" /></p>
> <ul class="errorlist"><li>This field is required.</li></ul>
> <p><label for="id_url">Url:</label> <input type="text" name="url"
> id="id_url" /></p>
> <ul class="errorlist"><li>This field is required.</li></ul>
> <p><label for="id_address">Address:</label> <input type="text"
> name="address" id="id_address" /></p>
> 
> <ul class="errorlist"><li>This field is required.</li></ul>
> <p><label for="id_range">Range:</label> <input type="text"
> name="range" id="id_range" /><input type="hidden" name="auth_id"
> id="id_auth_id" /></p>
> 
> No value is initialized for auth_id ... so perhaps the problem is in
> how I'm calling the constructor for newFenceForm?
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to