django forms as a pop up dialogue
18,099
Found the solution I was looking for here:
http://blog.raventools.com/create-a-modal-dialog-using-css-and-javascript/
Author by
shizznetz
Updated on June 15, 2022Comments
-
shizznetz almost 2 years
I just created a django form using this following documentation:https://docs.djangoproject.com/en/1.8/topics/forms/
My Forms.py is similar to this:
from django import forms class NameForm(forms.Form): your_name = forms.CharField(label='Your name', max_length=100)
My Html template is similar to this (from django doc):
<dialog id="addForm"> <form action="{% url "listing" %}" method="post" > {% csrf_token %} {{ form }} <input id="task_submit" type="submit" value="Submit"/> </form> </dialog> <button onlick="PopUp()">Add Listing </button> <script> function PopUp(){ document.getElementByID("addForm").showModal(); } </script>
However, I want my form to be a pop up dialogue when a user clicks on a button called "add tasks". I do not want the form to show until the user clicks a button called "add tasks". I have not been able to find any methods so far to do so while using Django Forms.
Question: How do I implement a pop up dialogue to display my current django form when a user clicks on a button?