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:
{% if contractForm.errors %}
Please correct the error{{ contractForm.errors|pluralize }}
below.
{% endif %}
{{ contractForm.as_p }}
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 django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.