Django: put data back into form fields

After a form fails validation (or before if you don’t want to use default values!) put data back into the form so that the user doesn’t have to start all over again.

def index(request):
	ff = FooForm( initial={'field_name':"hello!"})
	return render_to_response("index.html", {"myform":ff})

for some reason I forget this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s