oacpl/newsroom/admin.py

21 lines
523 B
Python
Raw Normal View History

2018-02-25 23:48:34 -05:00
from django.contrib import admin
from .models import Attachment, PressRelease
admin.site.register(Attachment)
@admin.register(PressRelease)
class PressRelease(admin.ModelAdmin):
list_display = ['title', 'created', 'creator']
fields = ['title', 'attachments']
filter_horizontal = ['attachments']
def save_model(self, request, instance, form, change):
user = request.user
instance = form.save(commit=False)
instance.creator = user
instance.save()
return instance