1234567891011 |
- from django.contrib import admin
- class ModelBaseAdmin(admin.ModelAdmin):
- list_display = ('creator', 'is_deleted', 'gmt_created', 'gmt_modified')
- readonly_fields = ['creator']
- def save_model(self, request, obj, form, change):
- if not obj.creator:
- obj.creator = request.user.username
- obj.save()
|