Django how do i work with button in a template -


i have button in templates, when click button create object. new django. correct way work buttons.

   <form action="" method="post">{% csrf_token %}     <input type=submit name="submit">     </form> 

views

           def create_object(request):            if 'submit' in request.post:                                                                                                        employee.object.create(emp_name='test',emp_email='test@gmail.com')             httpresponse(" ")  

try this

def create_object(request):     if 'submit' in request.post:     #employee.object.create(emp_name='test',emp_email='test@gmail.com')<--- commented out button = "<button>your button</button>" return render_to_response('your.html',{'button':button},context_instance=requestcontext(request)) 

template

{{button|safe}} <------------ show rendered button 

tell me if have problems in understanding code


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -