Make some little quality-of-life improvements to the Django admin for my models

This commit is contained in:
Danielle McLean 2017-10-29 22:44:11 +11:00
parent 63b0ec45e9
commit 75ed4503c8
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 9 additions and 2 deletions

View file

@ -8,6 +8,9 @@ class SyndicationInline(admin.TabularInline):
class EntryAdmin(admin.ModelAdmin): class EntryAdmin(admin.ModelAdmin):
date_hierarchy = 'published'
list_display = ('title', 'id', 'kind', 'published')
list_filter = ('kind',)
inlines = ( inlines = (
SyndicationInline, SyndicationInline,
) )

View file

@ -3,6 +3,10 @@ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from .models import Key, Profile, Site, User from .models import Key, Profile, Site, User
class SiteAdmin(admin.ModelAdmin):
list_display = ('name', 'icon', 'url')
class KeyInline(admin.TabularInline): class KeyInline(admin.TabularInline):
model = Key model = Key
extra = 1 extra = 1
@ -23,5 +27,5 @@ class UserAdmin(BaseUserAdmin):
) )
admin.site.register(Site) admin.site.register(Site, SiteAdmin)
admin.site.register(User, UserAdmin) admin.site.register(User, UserAdmin)

View file

@ -73,7 +73,7 @@ class Profile(models.Model):
display_name = models.CharField(max_length=100, blank=True) display_name = models.CharField(max_length=100, blank=True)
def __str__(self): def __str__(self):
return '{name}@{site}'.format(name=self.username, site=self.site) return self.url
@property @property
def name(self): def name(self):