Hi,
I'm trying to display a form in the following way:
1. creating a form
2. writing a view method that looks like this:
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
cd['subject'],
cd['message'],
cd.get('email', '[email protected]'),
['[email protected]'],
)
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm(initial='subject')
return render_to_response('contact_form.html', {'form': form})
3. creating a template:
<body>
<h1>Contact us</h1>
{% if form.errors %}
<p style="color: red;">
Please correct the error{{ form.errors|pluralize }} below.
</p>
{% endif %}
<form action="" method="post">
<table>
{{ form.as_table }}
----------------------------------------------------------------> not
working!
</table>
<input type="submit" value="Submit">
</form>
</body>
all i'm getting is :
Contact us:
Submit (button)
and only when i click the submit button i get the form that i wish for
+ some friendly errors (this field is required...)
any idea why?
appreciate your help,
cheers,
Lina
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---