Skip to content

Commit 5fea380

Browse files
committed
bug fixed : int conversion changed to float
1 parent b8d2eeb commit 5fea380

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

django_query_to_table/DjangoQtt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ def generateFromSql(cursor, title, sqltext, footerCols= None, htmlClass="", dire
4242
for d in data :
4343
for attr, value in dict(d).items() :
4444
if(attr in sumCols):
45-
sumOfColumn[attr]=sumOfColumn[attr]+int(str(value).replace(",", ""))
45+
sumOfColumn[attr]=sumOfColumn[attr]+float(str(value).replace(",", ""))
4646

4747
totalColumnSet = False
4848
if(sumCols != None) :
4949
for col, val in sumOfColumn.items() :
5050
if(val!="-") :
51-
sumOfColumn[col] = format(int(str(val)),",")
51+
sumOfColumn[col] = format(float(str(val)),",")
5252
elif (totalColumnSet == False) :
5353
sumOfColumn[col] = totalText
5454
totalColumnSet = True
5555

5656
# template to generate data from data retrieved from database
57-
template= "<center><table dir=\"{{direction}}\" border=\"1\" class=\"table table-striped {{htmlClass}}\" style=\"width:93%;font-family:'{{font}}'\"> <thead> <tr> <th colspan='{{columns|length|add:'1'}}' style=\"font-family:'{{font}}';font-weight: bold;\" > {{title}} </th> </tr> <tr style='background-color:{{headerRowColor}}'>{% if rowIndex == True %} <td align=\"center\"> </td> {% endif %} {% for c in columns %} <th>{{ c }}</th> {% endfor %} </tr> </thead> <tbody> {% for d in data %} <tr style='background-color:{% if forloop.counter0|divisibleby:'2' %} {{evenRowColor}} {% else %} {{oddRowColor}} {% endif %} ' > {% if rowIndex == True %} <td align=\"center\">{{ loop.index }}</td> {% endif %} {% for attr, value in d.items %} <td align=\"center\">{{ value }}</td> {% endfor %} </tr> {% endfor %} {% if sumOfColumn != None %} <tr style='background-color:#eee;font-weight: bold;'> <td></td> {% for a,v in sumOfColumn.items %} <td align=\"center\">{{ v }}</td> {% endfor %} </tr> {% endif %}</tbody> </table></center>"
57+
template= "<center><table dir=\"{{direction}}\" border=\"1\" class=\"table table-striped {{htmlClass}}\" style=\"width:93%;font-family:'{{font}}'\"> <thead> <tr> <th colspan='{{columns|length|add:'1'}}' style=\"font-family:'{{font}}';font-weight: bold;\" > {{title}} </th> </tr> <tr style='background-color:{{headerRowColor}}'>{% if rowIndex == True %} <td align=\"center\"> # </td> {% endif %} {% for c in columns %} <th>{{ c }}</th> {% endfor %} </tr> </thead> <tbody> {% for d in data %} <tr style='background-color:{% if forloop.counter0|divisibleby:'2' %} {{evenRowColor}} {% else %} {{oddRowColor}} {% endif %} ' > {% if rowIndex == True %} <td align=\"center\">{{ forloop.counter }}</td> {% endif %} {% for attr, value in d.items %} <td align=\"center\">{{ value }}</td> {% endfor %} </tr> {% endfor %} {% if sumOfColumn != None %} <tr style='background-color:#eee;font-weight: bold;'> <td></td> {% for a,v in sumOfColumn.items %} <td align=\"center\">{{ v }}</td> {% endfor %} </tr> {% endif %}</tbody> </table></center>"
5858

5959

6060

0 commit comments

Comments
 (0)