From 97f47713ab24fde7185820d1dafe0a55569c1ae9 Mon Sep 17 00:00:00 2001 From: Liron Shimrony Date: Sat, 28 Dec 2019 16:44:14 -0500 Subject: [PATCH] - Added Tags in the admin page - Added searching and filter capabilities in the Bookmarks section in the admin page --- bookmarks/admin.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bookmarks/admin.py b/bookmarks/admin.py index 7f4e65f..7c8dbc0 100644 --- a/bookmarks/admin.py +++ b/bookmarks/admin.py @@ -1,6 +1,17 @@ from django.contrib import admin -# Register your models here. -from bookmarks.models import Bookmark +from bookmarks.models import Bookmark, Tag -admin.site.register(Bookmark) +@admin.register(Bookmark) +class AdminBookmark(admin.ModelAdmin): + list_display = ('title', 'url', 'date_added') + search_fields = ('title', 'url', 'tags__name') + list_filter = ('tags',) + ordering = ('-date_added', ) + +@admin.register(Tag) +class AdminTag(admin.ModelAdmin): + list_display = ('name', 'date_added', 'owner') + search_fields = ('name', 'owner__username') + list_filter = ('owner__username', ) + ordering = ('-date_added', )