Галерея

This commit is contained in:
iriska-gri committed 2023-11-29 17:03:59 +03:00
1 parent be136d0f4f
commit c23cf63f6d
7 files changed
+142 -348

No files matched your search

+16
View File
@@ -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',)