1 from django.conf import settings
2 from django.contrib import admin
3 from django.contrib.contenttypes import generic
4 from philo.models import Tag, Attribute
5 from philo.forms import AttributeForm, AttributeInlineFormSet
8 COLLAPSE_CLASSES = ('collapse', 'collapse-closed', 'closed',)
11 class AttributeInline(generic.GenericTabularInline):
12 ct_field = 'entity_content_type'
13 ct_fk_field = 'entity_object_id'
17 classes = COLLAPSE_CLASSES
19 formset = AttributeInlineFormSet
20 fields = ['key', 'value_content_type']
21 if 'grappelli' in settings.INSTALLED_APPS:
22 template = 'admin/philo/edit_inline/grappelli_tabular_attribute.html'
24 template = 'admin/philo/edit_inline/tabular_attribute.html'
27 class EntityAdmin(admin.ModelAdmin):
28 inlines = [AttributeInline]
32 class TagAdmin(admin.ModelAdmin):
33 list_display = ('name', 'slug')
34 prepopulated_fields = {"slug": ("name",)}
35 search_fields = ["name"]
37 admin.site.register(Tag, TagAdmin)