From fff2d74815d0cb147e97d64c7d6bc633c308c60f Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 13 Apr 2019 11:03:53 -0500 Subject: added tags to links admin --- app/links/admin.py | 2 +- app/links/models.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/links/admin.py b/app/links/admin.py index b1aabc0..f967dde 100644 --- a/app/links/admin.py +++ b/app/links/admin.py @@ -11,7 +11,7 @@ from .models import Link @admin.register(Link) class LinkAdmin(admin.ModelAdmin): - list_display = ('title', 'admin_link', 'pub_date', 'status') + list_display = ('title', 'admin_link', 'pub_date', 'admin_tags') search_fields = ['title', 'description', 'url'] list_filter = ['status', TagListFilter] fieldsets = ( diff --git a/app/links/models.py b/app/links/models.py index ecea2d9..0255745 100644 --- a/app/links/models.py +++ b/app/links/models.py @@ -3,7 +3,7 @@ import datetime from random import randint from django.template.defaultfilters import striptags from django.urls import reverse -from django.utils.html import format_html +from django.utils.html import format_html, format_html_join from django.apps import apps from django.db import models from django.utils import timezone @@ -86,6 +86,13 @@ class Link(models.Model): return format_html('Visit Site' % (self.url)) admin_link.short_description = 'Link' + def admin_tags(self): + return format_html_join( + '\n', "{},", + ((tag.slug, tag.name) for tag in self.tags.all()) + ) + admin_tags.short_description = 'Tags' + @property def get_previous_published(self): return self.get_previous_by_pub_date(status__exact=1) -- cgit v1.2.3-70-g09d2