On 19 February 2010 10:27, Paul Stone <stoned...@gmail.com> wrote: > > > That's fine for one or two models. But what if I want to do this for a > > > number of models, in every view? What's the best way to do that > > > without code repetition? > > > > Using a ModelForm? > > > > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ > > Ok, I think I understand now. ModelForm always has a reference to the > request object.
Nope, it doesn't need that. You pass it request.POST (or GET). > So I can create a subclass of ModelForm (e.g > AuditModelForm) that I use as a base for all my forms. In the save() > method of AuditModelForm, I can set the updated_by field of the model > and do anything else I want. > > But yes, you can update the object in the save method. Dougal -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.