python - NameError - global name not defined -


i trying read data html forms , insert database. doing stuck error "nameerror @ /createemployee/ : global name 'get_post_param' not defined" ; paste code here. can me solve this.
views.py

def createemployee(request):     if request.method == "post":         username = get_post_param(request,"username")         designation = get_post_param(request,"designation")         employeeid = get_post_param(request,"employeeid")         contactnumber = get_post_param(request,"contactnumber")         project = get_post_param(request,"project")         dateofjoin = get_post_param(request,"dateofjoin")         employeedetails(username=username,designation=designation,employeeid=employeeid,contactnumber=contactnumber,project=project,dateofjoin=dateofjoin).save()         return render_to_response('createemployee.html')     else:         return render_to_response('createemployee.html') 

template.py

<form action="http://127.0.0.1:8000/createemployee/" method="post">  name: <input type="text" name="username" /><br /> designation: <input type="text" name="designation" /><br> employeeid: <input type="text" name="employeeid" /><br> contact number: <input type="text" name="contactnumber" /><br> project: <input type="text" name="project" /><br> date of join: <input type="text" name="dateofjoin" /><br> <input type="submit" value="submit" /><br /> </form> 

this simple problem. have not defined get_post_param.
did get_post_param idea?

simply define function called get_post_param fix it..

here's python shell session

>>> get_post_param(request, 'username') nameerror: not defined  >>> def get_post_param(request, param): ...    return request.post.get(param)         # or scrap idea of function 1 liner op anyways  >>> get_post_param(request, 'username'): 'my_username' 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -