Re: populate a form from database and show all item fields in a template

2009-03-01 Thread MarcoS
I solved it! I was getting drowning in my own spittle! This is the code in forms.py class BookForm(forms.Form): def __init__(self, *args, **kwargs): super(BookForm, self).__init__(*args, **kwargs) books = Book.objects.all() for item in books: field = '%s'

Re: populate a form from database and show all item fields in a template

2009-02-28 Thread MarcoS
> It sounds like you're looking for a modelform. I don't think I need modelform 'cause my purpose it's only show books items details with a checkbox for each one. I need to obtain html like this: Book title: "Harry Potter and the Philosopher's Stone" price: "25.00" Book title: "

Re: populate a form from database and show all item fields in a template

2009-02-28 Thread join.toget...@gmail.com
It sounds like you're looking for a modelform. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, s

Re: populate a form from database and show all item fields in a template

2009-02-27 Thread MarcoS
> Try using a multiplemodelchoice field with a checkboxselectmultiple widget. > > Alex Ok thanks, I've changed forms.py like this: -- forms.py -- class BookForm(forms.Form): book_item = forms.ModelMultipleChoiceField (queryset=Book.objects.all(), widget=forms.CheckboxSelectMultiple)

Re: populate a form from database and show all item fields in a template

2009-02-27 Thread Alex Gaynor
On 2/27/09, MarcoS wrote: > > Hi! wondering if someone could point me in the right > direction with this one: > > I'm trying to populate fields in a form with data from database: > i.e. suppose I've this model: > Try using a multiplemodelchoice field with a checkboxselectmultiple widget. Alex >

populate a form from database and show all item fields in a template

2009-02-27 Thread MarcoS
Hi! wondering if someone could point me in the right direction with this one: I'm trying to populate fields in a form with data from database: i.e. suppose I've this model: -- models.py -- class Book(models.Model): title = models.CharField(max_length=100) pages = models.IntegerField()