Hi,
I have written a form in forms.py that looks like this:
class ContractForm(forms.Form):
title = forms.CharField()
start_date = forms.DateField()
end_date = forms.DateField()
description = forms.CharField(widget=forms.Textarea)
client = forms.ModelChoiceField(queryset=Client.objects.all())
And in my view (yes i know there are problems with data not being
checked but the aim was to get the client field to display clients
associated with that user):
def addContractTEST(request):
if request.method == 'POST':
contractForm = ContractForm(request.POST)
title = request.POST['title']
start_date = request.POST['start_date']
end_date = request.POST['end_date']
description = request.POST['description']
client = request.POST['client']
user = request.user
contract =
Contract(title,start_date,end_date,description,client,user)
contract.save()
return HttpResponseRedirect('../../accounts/profile/')
else:
user = request.user
print user.username
contractForm = ContractForm()
return render_to_response('newcontract.html', {'ContractForm':
ContractForm})
And my newcontract.html:
<html>
<head>
</head>
<body>
{% if contractForm.errors %}
<p style="color: red;">
Please correct the error{{ contractForm.errors|pluralize }}
below.
</p>
{% endif %}
<form method="POST" action="">
{{ contractForm.as_p }}
<input type="submit" value="Submit" />
</form>
</body>
</html>
But all that appears is my submit button so what am I doing wrong?
Thanks in Advance,
Dean
--
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.