form_for_model and form_for_instance seem like complicated and clever ways to accomplish what basically boils down to a form that has a save method and can accept a model instance in its constructor method.
I propose we (or I rather) actually build it that way before 1.0. Form declaration: class MyForm(ModelForm): model = MyModel #optional def save(self, commit=True): # do custom save stuff here if needed Usage: def add_view(request): if request.POST: form = MyForm(request.POST) if form.is_valid() obj = form.save() ... else: form = MyForm() ... def change_view(request, id): obj = MyModel.objects.get(pk=id) if request.POST: form = MyForm(request.POST, obj=obj) if form.is_valid() obj = form.save() ... else: form = MyForm(obj=obj) ... ModelForm would be a declarative class that requires, at minimum, a model attribute. Other attributes would include: - formfield_callback (a function that takes a db field and **kwargs and returns a form field or None) - fields (a list of field names to include in the form) - exclude (a list of field names to exclude from the form) The biggest problem I see is that this would be entirely backwards incompatible with the way form_for_model and form_for_instance work now. (especially the latter) It *may* be possible to change form_for_X into some sort of hackish wrappers, but it wouldn't be pretty. If we don't actually do this, I'll eventually release it as a 3rd party package, but having it around would make some things in newforms-admin a lot more sane to implement. Joseph --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---