From 561d05632b988e2942987ce317671d13cc55bde9 Mon Sep 17 00:00:00 2001 From: Angus Goody Date: Mon, 25 Nov 2024 18:04:51 +0000 Subject: [PATCH] Refactor (#9) * better footer * added admin panel --- message/admin.py | 19 ++++++++++++++++++- poo/urls.py | 2 +- templates/_base.html | 22 +++++++++++----------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/message/admin.py b/message/admin.py index 8c38f3f..c583c79 100644 --- a/message/admin.py +++ b/message/admin.py @@ -1,3 +1,20 @@ from django.contrib import admin +from django.template.defaultfilters import truncatechars + +from message.models import Message + + +@admin.register(Message) +class MessageURLAdmin(admin.ModelAdmin): + + # Define a method to truncate content + def short_content(self, obj): + return truncatechars(obj.content, 35) + + short_content.short_description = 'Short Content' # Optional: Customize the column header + + # Display the new fields in the admin list view + list_display = ('slug', 'short_content', 'created_at') + search_fields = ('slug', 'content') + list_filter = ['created_at'] -# Register your models here. diff --git a/poo/urls.py b/poo/urls.py index c3f9e13..43778d7 100644 --- a/poo/urls.py +++ b/poo/urls.py @@ -20,7 +20,7 @@ path("admin/", admin.site.urls), path('', include('shortener.urls')), # Main app routing - path('message/', include('message.urls')), # Messager app routing + path('message/', include('message.urls')), # Message app routing ] diff --git a/templates/_base.html b/templates/_base.html index 8c49676..5646983 100644 --- a/templates/_base.html +++ b/templates/_base.html @@ -32,17 +32,17 @@