actually I feel comfortable with custom html stuff.. thats why.
ooopps yeah that was a typo since I typed everything while am on-the-
go :)

I am new to django so I don't really know what to do.
could you please a little more?
thanks

On Aug 20, 4:55 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> Why are you using your own <input> tags (just out of interest!)? It might be
> that you have just provided a cut down version of your code but from what I
> see, there are a few reasons why it may not be working properly.
>
> It looks like you are only passing the errors to the template, but not the
> other form values. If you want the previous data, you will need to put it in
> your context.
>
> Is any validation working at all, and is it saving any data to the db? It
> looks like you are calling is_valid on your POST data (not on an instance of
> your form object). If you want to pass your POST data to the form, you need
> to do something like this:
>
> f = ContactForm(request.POST)
>
> Or if you need to put more data in (or munged data):
>
> contact_instance = Contact(att=value)
> f = ContactForm(request.POST, instance=contact_instance)
>
> HTH
>
> Em
>
> > -----Original Message-----
> > From: django-users@googlegroups.com
> > [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> > Sent: 20 August 2008 11:24
> > To: Django users
> > Subject: Re: how to populate data again after validation
>
> > 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