On Saturday 31 October 2009 15:34:07 Ross wrote: > I'm new to Django and web programming in general and I'm trying to > write a simple page that will allow users to sign up for different > leagues. The sign up form will have multiple fields (name, phone, > address, etc). I've read over the forms documentation and the > modelforms documentation, but I'm still confused over when I should > use one or the other. I'm confused because it seems to me that since > any form where a user enters information commits that info to the > database, why wouldn't I always use ModelForm.Lastly, as a side- > question, can either of these be used in conjunction with generic > views, or must I write my own?
You can use generic views[1] and it is suggested you use modelforms with create/update/delete views. Model forms and forms do the same thing, just forms doesn't know the model to use and you need to manually define the fields, model form knows the model and builds your form, based on how you set up your model form class and model. When you wouldn't want to use model forms, is probably when you're using fields that aren't in the model, like a captcha field. Though, I woud suggest just using model forms, then when you run into that situation where model forms aren't enough, then build a form. Mike [1] http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views- generic-create-update-create-object -- I hope the ``Eurythmics'' practice birth control ...
signature.asc
Description: This is a digitally signed message part.

