Skip to content

Commit

Permalink
version 1.19.1 - resolved issues #63 and issue #66
Browse files Browse the repository at this point in the history
  • Loading branch information
pigletto committed Nov 20, 2019
1 parent 58ca117 commit a374ebf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2019.11.20 - 1.19.1
- Issue #63 - render_column method refactored into two separate methods
- Issue #66 - added format_html to the render_column output if get_absolute_url is used

2019.10.02 - 1.19.0
- Fixed backward compatibility with version 1.16
- Use columns.data field (if defined in JavaScript) to determine columns definition
Expand Down
16 changes: 11 additions & 5 deletions django_datatables_view/base_datatable_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging

from django.db.models import Q
from django.utils.html import escape
from django.utils.html import escape, format_html

from .mixins import JSONResponseView

Expand Down Expand Up @@ -132,7 +132,7 @@ def _column_value(obj, key):

return getattr(obj, key, None)

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

if self.escape_values:
value = escape(value)

if value and hasattr(obj, 'get_absolute_url'):
return '<a href="%s">%s</a>' % (obj.get_absolute_url(), value)

return value

def render_column(self, row, column):
""" Renders a column on a row. column can be given in a module notation eg. document.invoice.type
"""
value = self._render_column(row, column)
if value and hasattr(row, 'get_absolute_url'):
return format_html('<a href="{}">{}</a>', row.get_absolute_url(), value)
return value

def ordering(self, qs):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '1.19.0'
version = '1.19.1'

base_dir = os.path.dirname(__file__)

Expand Down

0 comments on commit a374ebf

Please sign in to comment.