Add cats to the admin and give them a more useful string representation

This commit is contained in:
Danielle McLean 2017-11-20 11:37:36 +11:00
parent 8fdaad5367
commit b63e2db584
Signed by: 00dani
GPG Key ID: 5A5D2D1AFF12EEC5
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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,))