I have a similar problem as a previously solved problem of mine, except this time solution doesn't seem to work:
How to auto insert the current user when creating an object in django admin?
Previously i used to override the save_model to stamp the user submitting the article. Now i need to do the same for comments, it doesn't seem to work anymore.
Anyone have any ideas?
Thanks a lot!
Jason
The saving isn't done in the InlineAdmin's save_form
, you have to look at save_formsets
in the ModelAdmin to which the inlines belong:
class MyAdmin(admin.ModelAdmin):
inlines = [MyInlineAdmin,.....]
def save_formset(self, request, form, formset, change):
formset.save()
if not change:
for f in formset.forms:
obj = f.instance
obj.user = request.user
obj.save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With