blob: ffead6060c681156b8f2a5e74794aef2986449da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from django.contrib import admin
from news.models import News
class NewsAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
list_display = ('title', 'date_created', 'date_updated')
def save_model(self, request, obj, form, change):
if not obj.id:
obj.author = request.user
obj.save()
admin.site.register(News, NewsAdmin)
|