From b63e2db584a294cbc110d4e53034f16c50d5c790 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 20 Nov 2017 11:37:36 +1100 Subject: [PATCH] Add cats to the admin and give them a more useful string representation --- entries/admin.py | 3 ++- entries/models.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/entries/admin.py b/entries/admin.py index c1cf273..dac64fb 100644 --- a/entries/admin.py +++ b/entries/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Entry, Syndication +from .models import Cat, Entry, Syndication class SyndicationInline(admin.TabularInline): @@ -16,4 +16,5 @@ class EntryAdmin(admin.ModelAdmin): ) +admin.site.register(Cat) admin.site.register(Entry, EntryAdmin) diff --git a/entries/models.py b/entries/models.py index d7c8143..876b017 100644 --- a/entries/models.py +++ b/entries/models.py @@ -28,6 +28,9 @@ class Cat(models.Model): name = models.CharField(max_length=255, unique=True) slug = models.CharField(max_length=255, unique=True) + def __str__(self): + return '#' + self.name + @property def url(self): return reverse('entries:cat', args=(self.slug,))