from django.contrib import admin

from .models import NodeType, Node


class NodeTypeAdmin(admin.ModelAdmin):
    list_display = ('name',)


class NodeAdmin(admin.ModelAdmin):
    list_display = ('name', 'abbreviation',)


admin.site.register(NodeType, NodeTypeAdmin)
admin.site.register(Node, NodeAdmin)

from django.contrib import admin

from .models import NodeType, Node


class NodeTypeAdmin(admin.ModelAdmin):
    list_display = ('name',)


class ParentInline(admin.TabularInline):
    model = Node.parents.through
    verbose_name = 'Parent relationship'
    verbose_name_plural = 'Parents'
    extra = 1
    fk_name = 'from_node'


class NodeAdmin(admin.ModelAdmin):
    list_display = ('name', 'abbreviation', 'typeOf',)
    list_filter = ('typeOf',)
    search_fields = ('name', 'abbreviation',)
    inlines = (ParentInline,)
    exclude = ('parents',)


admin.site.register(NodeType, NodeTypeAdmin)
admin.site.register(Node, NodeAdmin)

Improve Django Admin interface for Organisations
Improve Django Admin interface for Organisations

We have a lot of nodes now so adding some way of filtering by type and
searching by name seemed wise.

I've switched the multiselect box to pick parents for an interface that
is a little more sane when we have over a 1000 possible parents.
