I'm trying to automatically update audit fields "updated" and "updated_by" when an existing record is saved through a TabularInline subform. In my main forms (ModelAdmin) I do that with save_model():
5 class AuditAdmin(admin.ModelAdmin): 6 ordering = ['id'] 7 def save_model(self, request, obj, form, change): 8 if change: 9 obj.updated = datetime.datetime.now() 10 obj.updated_by = request.user.username 11 else: 12 obj.created = datetime.datetime.now() 13 obj.created_by = request.user.username 14 obj.save() But that doesn't seem to have any effect on TabularInline. Here's what I tried: 16 class AuditTabularAdmin(admin.TabularInline): 17 ordering = ['id'] 18 def save_model(self, request, obj, form, change): 19 if change: 20 obj.updated = datetime.datetime.now() 21 obj.updated_by = request.user.username 22 else: 23 obj.created = datetime.datetime.now() 24 obj.created_by = request.user.username 25 obj.save() The docs say "InlineModelAdmin shares many of the same features as ModelAdmin" -- I'm guessing save_model() is not one of them? I experimented with the features TabularInline adds to the ones *not shared* (?), but couldn't get any to do the trick. What is the recommended way to programmatically update fields upon saving an existing record through a TabularInline? Thanks very much for any help. Lee -- 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, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.