[Fixed]-How to create a table with links to change boolean values of a model instance in Django?

1👍

I think you are on the right track with your solution to post data through forms, sending data like : {‘state’: ‘received’}.
Also, I guess that Django Formsets might be useful for your design:
https://docs.djangoproject.com/en/1.9/topics/forms/formsets/.
Change the doc version if you don’t use Django 1.9

0👍

Another solution would be to have a dropdown/ChoiceField with id-s of all the objects for which it is possible to change order_received to True. You can make two more dropdowns for order_processed and order_delivered. Then, hide whole the form, and with some JS fiddling make the buttons to update the form values and send the form.

But, being honest, it will just not reuse the built in Django functions, so I would still advice to say what @phiberjenz mentions and make a formset. If you don’t want to use JS you could make the buttons next to the orders to work as submit buttons AND send the post that would be processed by your server-side form.

👤Art

0👍

I ended up creating a RedirectView that called a method on the instance changing the state of the order. This is called with a GET request, but super simple and according to https://docs.djangoproject.com/en/1.10/ref/class-based-views/base/ (at the bottom) the example shows exactly this.

Leave a comment