5👍
✅
1) admin.site.register(Annoucement, AnnoucementAdmin)
2) add 'return'
in the last of save_model
class AnnoucementAdmin(admin.ModelAdmin):
fields = ['title', 'description']
def save_model(self, request, obj, form, change):
obj.username = request.user
print("yes")
return super(AnnoucementAdmin, self).save_model(request, obj, form, change)
1👍
you have to pass the class AnnoucementAdmin, like this:
....
admin.site.register(Annoucement, AnnoucementAdmin)
Source:stackexchange.com