Skip to content

Commit

Permalink
Accept dataset expressed as list of either dict or OrderedDict to kee…
Browse files Browse the repository at this point in the history
…p dict ordering with old versions of Python
  • Loading branch information
morlandi committed Sep 4, 2024
2 parents cdbede7 + e77ee57 commit 2cf1de4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
History
=======

v1.2.9
------
- Accept dataset expressed as list of either dict or OrderedDict to keep dict ordering with old versions of Python

v1.2.8
------
- support for list params in query preview
Expand Down
5 changes: 3 additions & 2 deletions query_inspector/templatetags/query_inspector_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
import csv
import decimal
from collections import OrderedDict
from django.urls.exceptions import NoReverseMatch
from django import template
from django.urls import reverse
Expand Down Expand Up @@ -330,7 +331,7 @@ def get_foreign_value(obj, column_name):
return current_value

def get_cell_value(row, column):
if type(row) == dict:
if type(row) in [dict, OrderedDict, ]:
value = row.get(column['name'])
else:
if '__' not in column['name']:
Expand Down Expand Up @@ -438,7 +439,7 @@ def render_value_as_td(row, column, options):

# Experimental: detect all fields
if '*' in fields and num_rows > 0:
if type(rows[0]) == dict:
if type(rows[0]) in [dict, OrderedDict, ]:
fields = tuple(rows[0].keys())
else:
fields = [f.name for f in rows[0]._meta.fields]
Expand Down

0 comments on commit 2cf1de4

Please sign in to comment.