Skip to content
Snippets Groups Projects

WIP: Add ImageField to table. Advances #57.

Closed Tom Teichler requested to merge issue57 into master

Merge request reports

Approval is optional

Closed by Nik | KlampfradlerNik | Klampfradler 5 years ago (Jan 1, 2020 2:55pm UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
3 3 from django.utils.html import format_html
4 4
5 5
6 class ImageColumn(tables.Column):
7 def render(self, value):
8 return format_html('<img src="{}" />', value)
9
10
11 6 class PersonsTable(tables.Table):
12 7 class Meta:
13 8 attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'}
14 9
15 photo = ImageColumn("{% cropped_thumbnail person 'photo_cropping' max_size='20x30' %}")
10 photo = tables.TemplateColumn("<img src='/media/{{ person.photo }}' />")
  • That URL won't work.

    What's wrong with the same URL we use in other templates? Or even better, moving the image selection code into a template snippet, and re-using that in person_full, person_card and here?

  • Please register or sign in to reply
  • Nik | Klampfradler
    Nik | Klampfradler @nik started a thread on commit 716b41e1
  • 2 2
    3 3 {% extends "core/base.html" %}
    4 4
    5 {% load bootstrap4 i18n staticfiles cropping%}
    5 {% load bootstrap4 i18n staticfiles cropping %}
  • Tom Teichler unmarked as a Work In Progress

    unmarked as a Work In Progress

  • Tom Teichler marked as a Work In Progress

    marked as a Work In Progress

  • Closed as we will think all UI things over again after migrating to materialize.

  • Please register or sign in to reply
    Loading