On Apr 23, 9:03 pm, xpanta <[email protected]> wrote: > Thank you for the answers. > > The link provided by George is an excellent resource and I should > thank him for that. > > However my task is a bit simpler. Let's say I own a car company and I > have dealers in various cities. By clicking on each city name I get a > list of cars this city's dealer sells. This list varies from city to > city. Also, this list comes as a form where I (as the car company > owner) need to write the minimum and maximum selling price for each > car and submit it. It is a hypothetical scenario, but my project deals > with a very similar problem. > > in this example is the django's form class approach "better" than the > "classic" one (i.e. the one where I use a {% for car in citycars %} > loop and attach a car.id and the dealer.id to each input field and > process accordingly in the view)? > > I am new to django, so bear with me if I ask something trivial. > Thanks for your time, > Chris
OK, so that's an easy way of showing the fields. But now what? If you need to validate that the user has filled them in properly, how will you do it? How will you redisplay the form to show the errors? And presumably you want to do something with the data once the user has filled them in - so how will you save it to the database? All these things are taken care of by Django's form class. In your case, the model you describe doesn't seem to require the dynamic form technique, it's a simple matter of formsets - which again Django can define for you automatically from your model. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

