[Answer]-How to store values from html tags in database in django?

1👍

You can try like this.
In template:

<form action="/url" method="post">
{% csrf_token %}
question: <input type="text" name="question"><br>
answer: <input type="text" name="answer"><br>
<button type="button" onclick="myfunc()">save</button>
</form>

In views.py:

def Index(request):
   new_poll= Poll() #call model object
   d= request.POST
   new_poll.question= d['question']
   new_poll.question= d['answer']
   new_poll.save()
   return render_to_response('Index.html')
👤ruddra

Leave a comment