Hi Sophie,

I have just solved very similar problem. Thx you thousand times!!!

Mikuláš

Dne pondělí 1. srpna 2011 23:34:06 UTC+2 Sophie Hume napsal(a):
>
> Hi Stanislav 
>
> I think there's two ways you can do this... if you want to go down the 
> Forms route you actually want to be looking at Formsets [1], which 
> allow you to have a 'grid' of forms in a table with one row 
> representing each object. 
>
> If that seems like a steep learning curve to get your head around, and 
> you just want to try a quick-and-dirty approach, then you'd want a 
> loop in your template like {% for book in books %} ... {% endfor %} 
> then inside the loop build a <tr> for each item. If you make the first 
> tag in each row something like <select type="checkbox" 
> name="selected_book_id" value="{{ book.id }}" /> then follow it with 
> the other data fields, and have all of that wrapped in <form> ... </ 
> form> tags, obviously, then you should be able to get the list of 
> checked options in your view by reading 
> request.POST.getlist(selected_book_id). 
>
> Hope this helps! 
> Sophie 
>
> [1] https://docs.djangoproject.com/en/dev/topics/forms/formsets/ 
>
> On Aug 1, 1:35 pm, jocke khazad <khaz...@gmail.com> wrote: 
> > Hi Stanislav, 
> > 
> > I would sugest to create your own form object instead of creating input 
> tags 
> > directly in your template. 
> > 
> > Read this page which also explains how to validate your form on the 
> > serverside:https://docs.djangoproject.com/en/dev/topics/forms/ 
> > 
> > Use a boolean field to generate a checkbox. 
> > 
> > Best regards, 
> > Joakim 
> > 
> > On Mon, Aug 1, 2011 at 10:08 AM, Stanislav Nedelchev 
> > <stanf...@gmail.com>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 post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> > > To unsubscribe from this group, send email to 
> > > django-users...@googlegroups.com <javascript:>. 
> > > For more options, visit this group at 
> > >http://groups.google.com/group/django-users?hl=en.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/7e5439c2-7c5a-4494-8000-e99f7d4be920%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to