E
E
EgorLee2021-08-21 20:47:10
Django
EgorLee, 2021-08-21 20:47:10

How to make a form for selecting records from a database in django?

How to make a data selection form from the database, for example, as in the admin panel:

61213bc7669f6389344706.png

So that you can select several records from the table and do something with them, for example, delete or move

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
akrvch, 2021-08-22
@EgorLee

If I understood you correctly, then you need to add in the template where you will display the entries

<input type=“checkbox” value=“{{ entry.id }}” name=“delete”>
next to each entry, where value is the ID of your entry (ID of the entry in the database) that you want to operate on, and name is the name by which you will pull the values ​​of this input from the query. Note. entries = request.GET.get_list(“delete”)
And of course, all this should be inside the form
<form action=“url” method=“get”>
•••
<\form>

Where action is the url where this form will be submitted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question