Django tables with check box and delete button

357 views
Skip to first unread message

Praveen Kumar

unread,
Oct 16, 2018, 3:57:12 AM10/16/18
to django...@googlegroups.com
Hello,

Is there any django standard ways of creating a table with check boxes and let the user to select multiple rows using check box and the delete?

Appreciate if anyone can help to provide an example to achieve this.

Thanks,

Joel Mathew

unread,
Oct 16, 2018, 4:05:26 AM10/16/18
to django...@googlegroups.com
There's not much difference in doing this than what is standard practise. You just create the regular fields, loop over the ones creating multiple rows, assign unique name fields to each of them (you can use {{for.counter}} for this). You then capture the request with request.POST.getlist.




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB0oX7_URdpMiwqxkGrQq5tJaxeP5bqSDOspUukfs7d4gO_Mow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Praveen Kumar

unread,
Oct 16, 2018, 5:49:13 AM10/16/18
to django...@googlegroups.com
Currently I have a listview and a bootstrap table that displays the number of records. I had tried to use request.method POST, to get the list of checked boxes and feed it back to the delete action. However I get an error stating that 'POST is not allowed 405' and when I looked on the web, somewhere it states that POST doesn't work with django listview.

So any examples on generating a table with checkboxes which gives ability to delete multiple records using a delete button would be helpful!

Andréas Kühne

unread,
Oct 16, 2018, 7:11:23 AM10/16/18
to django...@googlegroups.com
Hi,

You can do whatever you want with any view - however listview per default only supports get requests. If you want to do a post, then you need to add the code for that yourself - All you need to do is add a method:

def post(self, request, *args, **kwargs)

Then you need to add the code that should delete the items there. See here for more information:

Unfortunately not the best examples but should get you pointed in the right direction.

Regards,

Andréas


Reply all
Reply to author
Forward
0 new messages