-
-
Notifications
You must be signed in to change notification settings - Fork 673
Expand file tree
/
Copy pathadmin.py
More file actions
27 lines (19 loc) · 739 Bytes
/
admin.py
File metadata and controls
27 lines (19 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from django.contrib import admin
from django.core.management import call_command
from app.blogs.models import BlogEntry, Feed, FeedAggregate
@admin.register(BlogEntry)
class BlogEntryAdmin(admin.ModelAdmin):
list_display = ['title', 'pub_date']
date_hierarchy = 'pub_date'
actions = ['sync_new_entries']
@admin.action(
description="Sync new blog entries"
)
def sync_new_entries(self, request, queryset):
call_command('update_blogs')
self.message_user(request, "Blog entries updated.")
@admin.register(FeedAggregate)
class FeedAggregateAdmin(admin.ModelAdmin):
list_display = ['name', 'slug', 'description']
prepopulated_fields = {'slug': ('name',)}
admin.site.register(Feed)