Галерея
This commit is contained in:
1 parent
be136d0f4f
commit
c23cf63f6d
7 files changed
+142
-348
No files matched your search
@@ -3,6 +3,20 @@ from django.utils.safestring import mark_safe
|
||||
|
||||
from .models import *
|
||||
|
||||
class GalleryInline(admin.TabularInline):
|
||||
model = Gallery
|
||||
fields = ( 'img', 'get_html_photo')
|
||||
readonly_fields=('get_html_photo',)
|
||||
can_delete = False
|
||||
show_change_link = False
|
||||
extra = 0
|
||||
|
||||
def get_html_photo(self, object):
|
||||
if object.img:
|
||||
return mark_safe(f"<img src='{object.img.url}' width=50>")
|
||||
|
||||
get_html_photo.short_description="Превью изображения"
|
||||
|
||||
class NewsAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'author', 'text', 'cdate', 'link', 'get_html_photo')
|
||||
readonly_fields=('get_html_photo',)
|
||||
@@ -21,6 +35,8 @@ class NewsAdmin(admin.ModelAdmin):
|
||||
|
||||
get_html_photo.short_description="Превью изображения"
|
||||
|
||||
inlines = [GalleryInline]
|
||||
|
||||
class CarouselsAdmin(admin.ModelAdmin):
|
||||
list_display=('title', 'cdate', 'enddate', 'get_html_photo', 'link','published', 'sender', 'order')
|
||||
readonly_fields=('get_html_photo',)
|
||||
|
||||
Reference in new issue
Block a user