-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.py
39 lines (31 loc) · 923 Bytes
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
from django.contrib import admin
from django import forms
from django.template.defaultfilters import slugify
from configurableproduct.admin import CProductAdmin
from configurableproduct.admin import (
ProductCharInline,
ProductBooleanInline,
ProductFloatInline,
ProductImageInline
)
from configurableproduct.models import (
ProductType,
CProduct,
)
from models import (
ProductTypeIcon,
STATIC_URL
)
from pprint import pprint
class ProductTypeIconAdmin(admin.ModelAdmin):
list_display = ('product_type', 'name', 'image_preview', )
def image_preview(self, obj):
return U"""
<span style='display:inline-block;margin:.5em;'>
<img src='{url}' />
</span>
<pre style='display:inline-block;'>{url}</pre>
""".format(url = obj.image.url)
image_preview.allow_tags=True
admin.site.register(ProductTypeIcon, ProductTypeIconAdmin)