Pass ID into Bootstrap delete Modal - html

I was following a tutorial online to try and create a delete modal from Bootstrap, but it is not picking up on the userid from my users table. The users table is stored on a sql database.
I keep getting the error: jinja2.exceptions.UndefinedError: 'list object' has no attribute 'id'
I have tried looking at similar questions on the stackoverflow site but I am unable to get this working, as I am still learning code and struggling with relating the answers to my setup.
Thanks in advance for anyone that can help.
So below is my delete function.
#app.route("/user/<int:user_id>/delete", methods=['POST'])
#login_required
def delete_user(user_id):
user = User.query.get_or_404(user_id)
db.session.delete(user)
db.session.commit()
flash('The account has been deleted', 'success')
return redirect(url_for('view_user'))
Then this is my html page.
{% extends "layout.html" %}
{% block content %}
<div class="container">
<div class="table-wrapper">
{% with messages = get_flashed_messages(with_categories=true)%}
{% if messages%}
{% for category, message in messages %}
<div class="alert alert-{{category}}">
{{ message}}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<h2>User Account <b>Details</b></h2>
</div>
<div class="col-sm-4">
<div class="search-box">
<i class="fas fa-search"></i>
<input type="text" class="form-control" placeholder="Search…">
</div>
</div>
</div>
</div>
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Username<i class="fa fa-sort"></i></th>
<th>Email Address<i class="fa fa-sort"></i></th>
<th>Role<i class="fa fa-sort"></i></th>
<th>Actions</th>
</tr>
</thead>
{% for user in user %}
<tbody>
<tr>
<td>{{user.id}}</td>
<td>{{user.username}}</td>
<td>{{user.email}}</td>
<td>{{user.role}}</td>
<td>
<a href="{{url_for('update_user', user_id=user.id)}}" class="edit" title="Edit"
data-toggle="tooltip"><i class="fas fa-edit"></i></a>
<button type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#deleteModal">Delete</button>
</td>
</tr>
</tbody>
{% endfor %}
</table>
<!-- Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Delete User?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<form action="{{ url_for('delete_user', user_id=user.id) }}" method="POST">
<input class="btn btn-danger" type="submit" value="Delete">
</form>
</div>
</div>
</div>
</div>
<div class="clearfix">
<div class="hint-text">Showing <b>5</b> out of <b>25</b> entries</div>
<ul class="pagination">
<li class="page-item disabled"><i class="fa fa-angle-double-left"></i></li>
<li class="page-item">1</li>
<li class="page-item">2</li>
<li class="page-item active">3</li>
<li class="page-item">4</li>
<li class="page-item">5</li>
<li class="page-item"><i class="fa fa-angle-double-right"></i></li>
</ul>
</div>
</div>
{% endblock content %}
Just in case it is needed this is my user table
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), nullable=False, unique=True)
email = db.Column(db.String(80), nullable=False, unique=True)
password = db.Column(db.String(120), nullable=False)
role = db.Column(db.String(80))

<form action="{{ url_for('delete_user', user_id=user.id) }}" method="POST">
<input class="btn btn-danger" type="submit" value="Delete">
</form>
user is python list so you can't able to use here that is why you are getting this error, so inorder to delete specific user you should use one user's route then you can deal with that user.
or
<td>
<i class="fas fa-edit"></i>
<button type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#deleteModal">Delete</button>
</td>
change to
<td class="btn btn-danger" onclick="return confirm('Are you to delete this user?')">Drop</td>
and remove the whole model.
This one will help you to have default model instread of Bootstrap model
Hope that will help you

Related

How to prevent Modal from hiding when submitting if there is an error in the form?

when I click the Add User button the modal is hiding even if the form has errors. If I reopen the modal the error messaged are there, I need to show the error messaged and not close the modal if the there is an error message.
I think I can use the {{form.errors}} to verify if there is an error message. But I don’t know how?
<div class="card-body d-flex justify-content-between">
<h4 class="box-title">Users</h4>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#add_user" data-whatever="" >Add a user</button>
<div class="modal fade" id="add_user" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="h3 mb-3 fw-normal text-center" id="exampleModalLabel">Create Account</h1>
</div>
<div class="modal-body">
<form action="" method="POST">
{% csrf_token %}
<div class="form-floating">
{{ form.username }}
<span class="text-danger">{{ form.errors.username }}</span>
</div>
<div class="form-floating">
{{ form.email }}
<span class="text-danger">{{ form.errors.email }}</span>
</div>
<div class="form-floating">
{{ form.password1 }}
<span class="text-danger">{{ form.errors.password1 }}</span>
</div>
<div class="form-floating">
{{ form.password2 }}
<span class="text-danger ">{{ form.errors.password2 }}</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button class=" btn btn-primary" type="submit" >Add User</button>
</div>
</div>
</form>
</div>
</div>
</div>
I used to the Django form for validation and error messages.
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class CustomUserCreationForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
username = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Username','class': 'form-control mb-3',}))
email = forms.CharField(widget=forms.EmailInput(attrs={'placeholder': 'Email','class': 'form-control mb-3',}))
password1 = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password','class': 'form-control mb-3',}))
password2 = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Confirm Password','class': 'form-control mb-3',}))
my function in views.py looks like this
#login_required(login_url= 'login')
#staff_member_required(login_url='home')
def dashboard(request):
User = get_user_model()
users = User.objects.all()
form = CustomUserCreationForm()
if request.method == 'POST':
form = CustomUserCreationForm(request.POST)
if form.is_valid():
form.save()
return redirect('dashboard')
context = {
'users' : users,
'form': form
}
return render(request, 'dashboard.html', context)
is there any solutions for this?
Simplest way to do it is to add if statement in modal div class:
<div class="modal fade {% if form.errors %}show{% endif %}" ...>
Sorry this is wrong! I did it withouth thinking. Sorry.
Correct answer:
Add this to your template (on bottom or top):
{% if form.errors %}
<script>
$(document).on('ready', function(){
$('#add_user').modal('show');
});
</script>
{% endif %}
This will invoke show on your modal at page load.
Another way to do it is somekind of validation with ajax or maby htmx(without reloading page)

Broken modal in flask

on my page I do cms for individual chapters that I have in the menu and on the page and I want new ones to be added and those that already exist so that they can be edited. I'm just doing it via jquery and bootstrap modal dialog but it doesn't want to work every time I click edit so my modal dialog doesn't appear and I get a 404 error. When adding chapters, nothing appears there at all, no error, no message or nothing in debug mode. I need help with that. Thank you in advance for your help.
PS: Deleting chapters works for me
HTML Code (updated):
{% extends "base.html" %} {% block content %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
{%if session["group"] == "Admin"%}
<div class="container">
<div class="row">
<div class="col md-12">
<h2>Kapitoly</h2>
<button type="button" class="btn btn-success pull-right" data-toggle="modal" data-target="#myModal">Přidat kapitolu</button>
<br>
<br>
{%with messages = get_flashed_messages()%}
{%if messages%}
{% for message in messages %}
<div class="alert alert-success alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label ="close">
<span aria-hidden="true">×</span>
</button>
{{message}}
</div>
{%endfor%}
{%endif%}
{%endwith%}
<table class="table table-striped">
<tr>
<th>ID</th>
<th>Ročník</th>
<th>Název</th>
<th>Akce</th>
</tr>
{% for row in chapters %}
<tr>
<td>{{row.0}}</td>
<td>{{row.1}}</td>
<td>{{row.2}}</td>
<td>
<a type="button" class="btn btn-primary" data-toggle="modal" data-target="#modaledit{{row.0}}">Upravit</a>
Smazat
</td>
</tr>
<div id="modaledit{{row.0}}" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Upravit kapitolu</h4>
</div>
<div class="modal-body">
<form action="{{ url_for('update') }}" method="POST">
<div class="form-group">
<label>Ročník:</label>
<input type="hidden" name="id" value="{{row.0}}">
<input type="text" class="form-control" name="year" value="{{row.1}}">
</div>
<div class="form-group">
<label>Název:</label>
<input type="text" class="form-control" name="title" value="{{row.2}}">
</div>
<div class="form-group">
<button class="btn btn-primary" type="sbumit">Upravit</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<div class="back">
Vrátit se zpátky.
</div>
</div>
</div>
</div>
{% endfor %}
</table>
</div>
</div>
<!-- Modal -->
<div id="mymodal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Vytvořit kapitolu</h4>
</div>
<div class="modal-body">
<form action = "/add_chapter" method="POST">
<div class="form-group">
<label>Ročník:</label>
<input type="text" class="form-control" name="year" required="1">
</div>
<div class="form-group">
<label>Název:</label>
<input type="text" class="form-control" name="title" required="1">
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Vytvořit</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{%endif%}
Flask code (updated):
#app.route("/manager_chapter")
#isLoggedIn
def manager_chapter():
cur = mysql.connection.cursor()
cur.execute("SELECT * FROM chapters")
data = cur.fetchall()
cur.close()
return render_template('manager_chapter.html', chapters=data, id_data=id)
#app.route("/add_chapter", methods=["POST"])
#isLoggedIn
def add_chapter():
if request.method == "POST":
flash("Kapitola je uspěšně přidaná.")
year = request.form['name']
title = request.form['email']
cur = mysql.connection.cursor()
cur.execute("INSERT INTO chapters (year, title) VALUES (%s, %s)", (year, title))
mysql.connection.commit()
return render_template('manager_chapter.html')
#app.route('/update_chapter/<string:id_data>', methods=['POST','GET'])
#isLoggedIn
def update(id_data):
if request.method == 'POST':
id_data = request.form['id']
year = request.form['year']
title = request.form['title']
cur = mysql.connection.cursor()
cur.execute("""
UPDATE chapters
SET year=%s, title=%s
WHERE id=%s
""", (year, title, id_data))
flash("Kapitola je uspěšně upravená.")
mysql.connection.commit()
return redirect(url_for('manager_chapter'))
#app.route('/delete_chapter/<string:id_data>', methods=['GET'])
def delete(id_data):
flash("Kapitola je uspěšně smazána.")
cur = mysql.connection.cursor()
cur.execute("DELETE FROM `chapters` WHERE id=%s", (id_data,))
mysql.connection.commit()
return render_template('manager_chapter.html')
Example 404 error after clicking edit in one of the chapters:
Next time, please translate your source code before posting it, if you are posting to English speakers. Based on your comments, I'm going to assume your edit button is this one
Upravit
You have both an href and data-target attribute. The latter is for the modal dialog. I don't believe you can have both and have them point to different urls. According to [bootstrap][1] documentation, you should use the href link and its value should be the id of your modal target. So I think your code should be
Upravit
or
<a type="button" class="btn btn-primary" data-toggle="modal" data-target="#modaledit{{row.0}}">Upravit</a>
If we assume your modal is not being triggered because it is being seen as a straight hyperlink and so the url in the href is being triggered, it opens up a second problem. Your flask route for that url has code only for a POST. You need to add code for the GET bit. In addition, your route has a variable for id_data but that variable is not part of your route i.e. you should have
#app.route('/update_chapter/<string:id_data>', methods=['POST','GET'])
#isLoggedIn
def update(id_data):
UPDATES - Based on comments by OP
Your button code now calls the modal.
The modal has a form and the form has a hidden field for the chapter id. Based on this, your route should now be
#app.route('/update_chapter', methods=['POST'])
#isLoggedIn
def update():
if request.method == 'POST':
id_data = request.values.get("id", None)
# I prefer to use request.values.get so that I don't
# have to worry about if my method is a POST or GET
[1]: https://getbootstrap.com/docs/4.1/components/modal/

Cannot retrieve data from my flask CRUD application from mysql table even though its getting inserted without any error

Here's the python snippet
#app.route('/oxygenadmin')
#is_logged_in
def oxygenadmin():
cur=mysql.connection.cursor()
cur.execute("SELECT * FROM oxygen")
data =cur.fetchall()
cur.close()
return render_template('oxygenadmin.html', oxygen=data)
#app.route('/insert', methods=['POST'])
#is_logged_in
def insert():
if request.method == 'POST':
name = request.form['name']
contact = request.form['contact']
email = request.form['email']
place = request.form['place']
cur = mysql.connection.cursor()
cur.execute("INSERT INTO oxygen(name, contact, email, place) VALUES (%s, %s, %s, %s)",(name,contact,email,place))
mysql.connection.commit()
flash("Data inserted successfully", 'success')
return redirect (url_for('oxygenadmin'))
return render_template ('oxygenadmin.html')
And here's the html snippet
<div class="row">
<div class="col md-12">
<h2> Oxygen Details <button type="button" class="btn btn-success pull-right" data-toggle="modal" data-target="#mymodal">Enter New Data</button> </h2>
<table class="table table-striped">
<tr>
<th>ID</th>
<th>Name</th>
<th>Contact No.</th>
<th>Email</th>
<th>Place</th>
<th>Action</th>
</tr>
{% for row in oxygen %}
<tr>
<td>{{row.0}}</td>
<td>{{row.1}}</td>
<td>{{row.2}}</td>
<td>{{row.3}}</td>
<td>{{row.4}}</td>
<td>
Edit
Delete
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
and...
<div id="mymodal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Please insert data!</h4>
</div>
<div class="modal-body">
<form action="{{url_for('insert')}}" method="POST">
<div class="form-group">
<label>Name:</label>
<input type="text" class="form-control" name="name" required='1'>
</div>
<div class="form-group">
<label>Contact No. :</label>
<input type="text" class="form-control" name="contact" required='1'>
</div>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email">
</div>
<div class="form-group">
<label>Place</label>
<input type="text" class="form-control" name="place" required='1'>
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Insert Data</button>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I somehow just cant get it to appear on my page
Here's how it looks
in the website itself
But it's getting inserted in the actual database though
Didnt paste the entire picture because there are some personal details
The table name is oxygen, I probably think it's doing something with the name itself , I just cant get it
Changing this...
{% for row in oxygen %}
<tr>
<td>{{row.0}}</td>
<td>{{row.1}}</td>
<td>{{row.2}}</td>
<td>{{row.3}}</td>
<td>{{row.4}}</td>
<td>
Edit
Delete
</td>
</tr>
{% endfor %}
to
{% for row in oxygen %}
<tr>
<td>{{row["id"]}}</td>
<td>{{row["name"]}}</td>
<td>{{row["contact"]}}</td>
<td>{{row["email"]}}</td>
<td>{{row["place"]}}</td>
<td>
Edit
Delete
</td>
</tr>
{% endfor %}
solves the issue

Two CSS Elements next to each other

I tried several hours to get a django forms on same height as the table but somehow it doesnt work properly the django forms go further and further down as i add more data to my table but i want it to stick on top of the div here is my html code:
<div style="display:inline-block;margin-left:10%;width:30%">
{% if status == "O" %}
<form action="{% url 'aktentabelleadd'%}" method="post" style="margin-left:10%;margin-right:5%;border:solid;border-color:white;border-radius: 5px;width:50%">
{% csrf_token %}
<h3 style="color:white;text-align:center">Akte hinzufügen</h3>
<input type="hidden" name="mitglied" value="{{container}}"/>
<input type="hidden" name="benutzer" value=" {{request.user.username}}"/>
<input type="hidden" name="status" value="{{status}}" />
<div style="color:white;margin-left:12%;margin-top:1%;margin-bottom:1%">{{aktenform}}
<button class="btn btn-primary" type="submit" value="hinzufügen">hinzufügen</button>
</div>
</form>
{% endif %}
</div>
<div style="display:inline-block;width:45%">
<table id="myTable" style="border-color:white;border-radius:6px">
<tr style="border:solid;border-color:white;padding-bottom:1%;padding-left:1%;border-radius:6px;color:white">
<th class="spaltenname" onclick="sortTable(0)">Aktenbarcode</th>
<th class="spaltenname" onclick="sortTable(1)">Ersteller</th>
<th class="spaltenname" onclick="sortTable(2)">Startdatum</th>
<th class="spaltenname" onclick="sortTable(3)">Kundennummer</th>
<th class="spaltenname" onclick="sortTable(4)">Aktionen</th>
</tr>
{%for Akte in akte_list reversed %}
<tr>
<td class="cell">{{Akte.Aktenbarcode}}</td>
<td class="cell">{{Akte.user}}</td>
<td class="cell">{{Akte.Startdatum | date:"d.m.Y" }}</td>
<td class="cell">{{Akte.kundennr}}</td>
<td class="cell">
<form action="{% url 'aktedelete' %}" method="post" name="{{Akte.Aktenbarcode}}">
{% csrf_token %}
<!--<input class="btn btn-primary" type="submit" value="{{Akte.Aktenbarcode}}"/> -->
{% if status == "O" %}
<input class="btn btn-primary" data-toggle="modal" data-target=#myModal-{{ forloop.counter }} form="{{Akte.Aktenbarcode}}" type="submit" value="Akte entfernen"/>
<input type="hidden" name="aktenbarcode" value="{{Akte.Aktenbarcode}}" />
<input type="hidden" name="mitglied" value="{{container}}"/>
<input type="hidden" name="benutzer" value="{{request.user.username}}"/>
<input type="hidden" name="status" value="{{status}}" />
<!-- Modal -->
<div class="modal fade" id="myModal-{{ forloop.counter }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle" style="color:black">Akte: {{Akte.Aktenbarcode}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" style="color:black"> Wollen Sie diese Akte unwiderruflich aus dem Container löschen?</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" value="Save" onclick="form_submit()">Ja, ich bin mir sicher</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" value="Cancel">Nein</button>
</div>
</div>
</div>
</div>
<!-- ModalEnd-->
</form></td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
and here is the img of the problem, i want the akteforms to be on the same height as the table header

Issue with creating new html/css elements inside jinja loops (Django)

I am trying to create new html/css elements inside a jinja loop while within a form , where i am filling data that I brought from a django view. All the normal browser side stuff like pop-up on button clicks is good. But only the last button successfully makes a GET request whereas every button must do. This is my form here :
<form method="GET" action="{% url 'search_results' %}">
{% csrf_token %}
{% for name,quali,field,address,pro,c in data %}
<div class="ser_tile">
<img src={{pro}} id="user_dr" >
<button class="btn_tile" id="btn1" data-toggle="modal" data-target="#{{c}}">Visit Page</button>
<button class="btn_tile" id="btn1" data-toggle="modal" data-target="#b{{c}}">Book Appointment</button><br/><br/>
<span >
Name: {{name}}
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span><br/>
Degree: {{quali}}<br/>
Specialist: {{field}}<br/>
Hospital: Pradyumna Bal Memorial Hospital<br/>
Address: {{address}}
</span>
</div><br>
<div class="modal fade" id="{{c}}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Profile</h4>
</div>
<div class="modal-body">
<center>
<div class="modal_cov"></div>
<img class="modal_ico" src={{pro}}><br/><b>{{name}}</b><br/>Pradyumna Bal Memorial Hospital
<hr/>
</center>
<div>
<table>
<tr>
<td class="td"><b> Specialist:</b></td>
<td>
{{field}}
</td>
</tr>
<tr>
<td><b> Ratting:</b></td>
<td>
3
</td>
</tr>
<tr>
<td><b>Available On:</b></td>
<td>
Monday(10:30AM : 5:00PM), Thursday(10:30AM : 1:00PM) , Saturday(10:30AM : 1:00PM)
</td>
</tr>
<tr>
<td><b>Minimum Chagre:</b></td>
<td>
Rs:500/-
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer qq{{c}}">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button class="btn_tile" data-toggle="modal" data-target="#b{{c}}" data-dismiss="modal">Book Appointment</button>
</div>
</div>
</div>
</div>
<script>
$(".btn_tile").click(function(event){
event.preventDefault();
});
</script>
<div class="modal fade" id="b{{c}}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Profile</h4>
</div>
<div class="modal-body">
<center>
<div class="modal_cov"></div>
<img class="modal_ico" src={{pro}}><br/><b>{{name}}</b><br/>Pradyumna Bal Memorial Hospital
<hr/>
</center>
<div>
<table>
<tr>
<td class="td"><b> Date:</b></td>
<td>
<input name="date" class="td_in" type="date">
</td>
</tr>
<tr>
<td ><b> Time:</b></td>
<td>
<input name="time" class="td_in" type="time">
</td>
<td>
<b>Avilable times: </b>
</td>
<td>
1:00PM, 3:00PM
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" name="book" value="confirm" class="btn_tile" >Confirm Booking</button>
</div>
</div>
</div>
</div>
<hr/>
{% endfor %}
</form>
This particular button (Confirm Booking) has to generate a GET request but it fails to. The array request.GET() returns None.
here is a screenshot of the popup
You could try inserting the button into a form as below....
<form method="get" action="<YOUR DESIRED ACTION>">
<button type="submit" name="book" value="confirm" class="btn_tile" >Confirm Booking</button>
</form>
hope it helps...