On Sun, 2008-01-06 at 01:32 -0800, shabda wrote:
> I have a form, to which I want to pass some data when it is first
> dipalyed,
> My form is,
> class EditPage(forms.Form):
>     text = forms.CharField(widget = forms.Textarea)
>     edit_summary = forms.CharField()
> 
> In my view I bind data to this form as
>     if request.method == 'GET':
>         page = Page.objects.get(slug = slug)
>       edit_form = forms.EditPage({'text':page.current_revision.wiki_text})
> 
> Since this is a edit page, we need to display the previous data, but
> the edit_summary field must be empty. However as soon as I bind any
> thing to the form the validation fires and so in the template errors
> are displayed, as form.errors is not empty. We can not se form.errors,
> as that field is Immultable. SO how do I add data to the form when it
> is first displayed?

You need to use the "initial" parameter for supplying initial data. See
http://www.djangoproject.com/documentation/newforms/#initial for the
details.

Regards,
Malcolm

-- 
Success always occurs in private and failure in full view. 
http://www.pointy-stick.com/blog/


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