python - save values in database using django -
i have custom form , whenever fetch form values save in database display error ( applicationform() got unexpected keyword argument 'job_title' ) , values not save in table.
views.py :-
def applicationvalue(request): if request.method == 'post': getjobtitle = request.post['jobtitle'] getintable = applicationform(job_title=getjobtitle) getintable.save() print getjobtitle return httpresponse(getintable) else: return render_to_response('registration/applicationform.html')
my form :-
<form method="post" action="#" class="form-horizontal" id="applicationform" name="appform"> <input type="text" id="u_jobtitle" class="input-xlarge" name="jobtitle" value=" " /> <button class="btn btn-gebo" type="submit" name="usubmit">save changes</button>
whenever fetch values form save values in table field " job_title " display error :-
applicationform() got unexpected keyword argument 'job_title'
change input
field name job_title
in html
<input name="job_title" type="text" id="u_jobtitle" class="input-xlarge" value=" " /> -------------^ changed
and in view
def applicationvalue(request): if request.method == 'post': #dont need #getjobtitle = request.post['jobtitle'] #---------------------------use request.post getintable = applicationform(request.post) getintable.save() print getjobtitle return httpresponse(getintable) else: return render_to_response('registration/applicationform.html')
it better if use same form render html instead of hand coding it.
Comments
Post a Comment