class ServiceInline(admin.TabularInline):
model = Service
class PlanAdmin(admin.ModelAdmin):
inlines = [ServiceInline]
class ServiceAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
instance = form.save(commit = False)
if not instance.created_at and not instance.modified_at:
instance.created_by = request.user
instance.modified_by = request.user
instance.save()
form.save_m2m()
return instance
I have overrided the save_model(self, request, obj, form, change): method of Service class in it’s admin class. But this overrided method is not getting called when a Service object added via Inline (Plan’s page). Any suggestions?
Rather than using the
save_modelfunction in the admin, which I don’t think is going to work, what about the following: