Dear All,
When I put this modal form in my code (cf. template.html), it make django soooo slowly
This kind of modal form works fine with small base but not with a large base my ‘People_Main’ database is around 30 000 object.
models.py
class Peoples_Affaires_Clients(models.Model):
affaire = models.ForeignKey(Affaires_Main, on_delete=models.SET_NULL, null=True)
people = models.ForeignKey(Peoples_Main, on_delete=models.SET_NULL, null=True)
views.py
Affaires_Clients_FormSet = inlineformset_factory(Affaires_Main, Peoples_Affaires_Clients, can_delete=True, fields=('people', ))
my_affaire_clients_formset_form = Affaires_Clients_FormSet(instance=my_affaire_main)
Template.html
<!-- Modal Infos -->
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ my_affaire_clients_formset_form.management_form }}
<div class="modal fade" id="ModalClients" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-info modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Modifications - Clients</h4>
</div>
<div class="modal-body">
<table class="table table-hover table-borderless table-sm" id="table">
<thead>
<tr>
<th>People</th>
<th>Nom</th>
<th>Prenom</th>
</tr>
</thead>
<tbody>
{% for uform in my_affaire_clients_formset_form %}
{{ uform.id }}
<tr>
<td>
<div class="form-group input-group">
{% render_field uform.people class="form-control" placeholder="[-- people --]" %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-light" type="button" data-dismiss="modal">Close</button>
<button class="btn btn-secondary" name="btn_affaire_clients" type="submit">Save</button>
</div>
</div>
</div>
</div>
</form>
If you have an idea
Thanks a lot
Thais