I am just using...

model...
class Contact(models.Model):
        Name = models.CharField(max_length=100)
        email = models.CharField(max_length=100)
        comments = models.TextField(blank=False)

form...
class ContactForm(ModelForm):
        Name = forms.CharField(label='Name')
        email = forms.EmailField(label='Email')
        comments = forms.CharField(label='Comments',widget=forms.Textarea)

        class Meta:
                model = Contact

views...
f = ContactForm()
f = request.POST
if f.is_valid():
    f.save()
    return HttpResponseRedirect('/home/')
else:
    ctx = {}
    ctx['errors'] = f.errors
    return render_to_response('contact.html',ctx)

when it doesn't save because validation failed, it renders
contact.html again, but blank. All previous data lost.

On Aug 20, 4:07 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How are you doing your validation? Is the form populating a model instance
> or doing something else?
>
> I would be helpful to see some of the function in your views file.
>
> Em
>
> > -----Original Message-----
> > From: django-users@googlegroups.com
> > [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> > Sent: 20 August 2008 10:45
> > To: Django users
> > Subject: how to populate data again after validation
>
> > I am not using builtin {{form}} to print form in template. I
> > am using my own <input> things.
> > Now, after validation, when it shows error and comes back to
> > form, all the data has disappeared.
> > How can I keep data in fields even after validation.
>
> > I am using render_to_response
--~--~---------~--~----~------------~-------~--~----~
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