Skip to content

Commit a374ebf

Browse files
committedNov 20, 2019
version 1.19.1 - resolved issues #63 and issue #66
1 parent 58ca117 commit a374ebf

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed
 

‎CHANGES

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019.11.20 - 1.19.1
2+
- Issue #63 - render_column method refactored into two separate methods
3+
- Issue #66 - added format_html to the render_column output if get_absolute_url is used
4+
15
2019.10.02 - 1.19.0
26
- Fixed backward compatibility with version 1.16
37
- Use columns.data field (if defined in JavaScript) to determine columns definition

‎django_datatables_view/base_datatable_view.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33

44
from django.db.models import Q
5-
from django.utils.html import escape
5+
from django.utils.html import escape, format_html
66

77
from .mixins import JSONResponseView
88

@@ -132,7 +132,7 @@ def _column_value(obj, key):
132132

133133
return getattr(obj, key, None)
134134

135-
def render_column(self, row, column):
135+
def _render_column(self, row, column):
136136
""" Renders a column on a row. column can be given in a module notation eg. document.invoice.type
137137
"""
138138
# try to find rightmost object
@@ -154,9 +154,15 @@ def render_column(self, row, column):
154154

155155
if self.escape_values:
156156
value = escape(value)
157-
158-
if value and hasattr(obj, 'get_absolute_url'):
159-
return '<a href="%s">%s</a>' % (obj.get_absolute_url(), value)
157+
158+
return value
159+
160+
def render_column(self, row, column):
161+
""" Renders a column on a row. column can be given in a module notation eg. document.invoice.type
162+
"""
163+
value = self._render_column(row, column)
164+
if value and hasattr(row, 'get_absolute_url'):
165+
return format_html('<a href="{}">{}</a>', row.get_absolute_url(), value)
160166
return value
161167

162168
def ordering(self, qs):

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22
import os
33

4-
version = '1.19.0'
4+
version = '1.19.1'
55

66
base_dir = os.path.dirname(__file__)
77

0 commit comments

Comments
 (0)