How to Display the Actual Image Instead of Its Path on the Admin Page(sqladmin)?

I’m working on an application with an admin interface, and I want to show the actual image rather than just its path in the admin page view. Below is my current code:
https://github.com/aminalaee/sqladmin

Title

How to Display the Actual Image Instead of Its Path on the Admin Page?

Description

I’m working on an application with an admin interface, and I want to show the actual image rather than just its path in the admin page view. Below is my current code:

Admin View

class PhotosAdmin(ModelView, model=Photos):
    column_list = [
        'id',
        'application_id',
        'url_photo',
    ]
    can_delete = False
    name = "Фотка"
    name_plural = "Фотки"
    icon = "fa-solid fa-camera"

Models

class Photos(Base):
    """Model representing a photo tied to an application."""

    __tablename__ = 'photos'

    id: Mapped[intpk]
    application_id: Mapped[int] = mapped_column(
        Integer,
        ForeignKey('applications.id', ondelete="CASCADE"),
        nullable=False
    )
    url_photo: Mapped[str] = mapped_column(String(255), nullable=False)
    application: Mapped["Applications"] = relationship("Applications", back_populates="photos")

    def __str__(self):
        return f"Фотка {self.id}, {self.application_id}"

Router and Functions

async def save_photo(file: UploadFile, application_id: int):
    file_location = f'app/static/images/{application_id}_{file.filename}'
    with open(file_location, "wb+") as buffer:
        shutil.copyfileobj(file.file, buffer)

    photo = await PhotosDAO.add(
        application_id=application_id,
        url_photo=file_location
    )

@router_application.post("/add/")
async def active_application(
        name: Annotated[str, Form()],
        phone_number: Annotated[str, Form()],
        email: Annotated[str, Form()],
        description: Annotated[str, Form()],
        fileInputFirst: Annotated[UploadFile, File()],
        fileInputSecond: Union[UploadFile, None] = None,
        fileInputThird: Union[UploadFile, None] = None,
):
    application = await ApplicationsDAO.add(
        name=name,
        phone_number=phone_number,
        email=email,
        description=description,
    )

    if application is None:
        raise ApplicationCreateException
    if fileInputFirst.filename.strip() != '':
        await save_photo(fileInputFirst, application.id)
    if fileInputSecond.filename.strip() != '':
        await save_photo(fileInputSecond, application.id)
    if fileInputThird.filename.strip() != '':
        await save_photo(fileInputThird, application.id)

Question

How can I modify this setup so that the actual images appear in the admin interface instead of just the path?

So far, I’ve set up the admin view, models, and router functions as described above. The current configuration allows displaying the path to the image in the admin panel. However, I haven’t been able to display the actual image instead of the URL. I am looking for suggestions on how to modify the code or what properties to include to achieve this functionality.

New contributor

rezuce is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật