Something like this:
@login_required
def batch_delete_bill_item(request):
if request.method == 'POST':
if request.POST.getlist('checks[]'):
selecteditems = request.POST.getlist('checks[]')
for sel in selecteditems:
item = get_object_or_404(billitem, code=sel)
try:
code = item.code
In the template you can have something like this:
{% for item in appointment_items %}
<input type="checkbox" name="checks[]" value="{{ item.pid }}" />
{% endfor %}
On Sat, 27 Oct 2018 at 18:01, Joel <[email protected]> wrote:
>
> Very simple. Give each checkbox a unique name, and process the submit request
> by reading request.POST.getlist.
>
> On Sat, 27 Oct, 2018, 5:52 PM nitesh rawat, <[email protected]> wrote:
>>
>> Hi Stanislav,
>> I hope you get the solution to your problem, if you can , share the code.
>> Thanks.
>>
>> On Monday, August 1, 2011 at 1:38:33 PM UTC+5:30, Stanislav Nedelchev wrote:
>>>
>>> Hi everyone,
>>> I'm quite new to django and still learning.
>>> But I face a problem that i can't solve.
>>> I have the following very simple example.
>>> Let say that I have one model for Books.
>>>
>>> class Book(models.Model):
>>> name = models.CharField(max_length=50,unique = True)
>>> description = models.TextField(blank = True)
>>> status = models.CharField(max_length=50,unique = True)
>>> created_on = models.DateTimeField(auto_now=True)
>>> def __unicode__(self):
>>> return self.name
>>>
>>> If I search for all books for example.
>>> I want to display table with result where first column is checkbox.
>>> And if I check some books and hit button delete to be able to delete
>>> them.
>>> Also I what to have one input field or drop down where i can choose
>>> "out of order" and click button update to change status of all slected
>>> books to "out of order"
>>> I'm reading the documentaion but I can't find how to do it.
>>> I made one template where I generate table with results.But I can't
>>> process checked books.
>>> I added manually delete button and form in template.
>>> But maybe I must use Forms instead.
>>> Any hint or example how to acomplish this will be very usefull.
>>>
>>>
>>> And sorry for my bad english.
>>> Best regards
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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/1b83c976-4432-4183-b60f-df8fc110a9e3%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
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/CAA%3Diw_8TfnxL4PB00sV3Y2EEqmDAeni3_zkhx7m0WyFfxsLJ0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.