spejstore-new/storage/admin.py

28 lines
658 B
Python
Raw Normal View History

2016-09-29 20:20:10 +00:00
from django import forms
from django.contrib import admin
from .models import Item, ItemImage, Category
class ItemForm(forms.ModelForm):
name = forms.CharField(widget=forms.TextInput())
class Meta:
model = Item
exclude = []
class ItemImageInline(admin.TabularInline):
model = ItemImage
extra = 1
class ItemAdmin(admin.ModelAdmin):
2017-02-15 03:01:47 +00:00
list_display = ('_name', 'uuid', 'props', 'path')
2016-09-29 20:20:10 +00:00
list_filter = ('categories',)
form = ItemForm
inlines = [ItemImageInline]
2017-02-15 03:01:47 +00:00
def _name(self, obj):
return '-' * obj.get_level() + '> ' + obj.name
2016-09-29 20:20:10 +00:00
admin.site.register(Item, ItemAdmin)
admin.site.register(Category)