Skip to content

Commit

Permalink
id replacement by pk
Browse files Browse the repository at this point in the history
  • Loading branch information
telmobarros committed Jan 31, 2022
1 parent be47467 commit 5bd7550
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions admirarchy/utils.py
Expand Up @@ -289,7 +289,7 @@ def hook_get_results(self, changelist: 'HierarchicalChangeList'):
continue

try:
setattr(item, self.CHILD_COUNT_MODEL_ATTR, stats[item.id])
setattr(item, self.CHILD_COUNT_MODEL_ATTR, stats[item.pk])

except KeyError:
setattr(item, self.CHILD_COUNT_MODEL_ATTR, 0)
Expand Down Expand Up @@ -370,7 +370,7 @@ def hook_get_results(self, changelist: 'HierarchicalChangeList'):

for result in result_list:

if result.id in leafs:
if result.pk in leafs:
setattr(result, self.CHILD_COUNT_MODEL_ATTR, 0)
else:
# Too much pain to get real stats, so that'll suffice.
Expand All @@ -388,12 +388,12 @@ def hook_get_results(self, changelist: 'HierarchicalChangeList'):
try:
grandparent_id = changelist.model.objects.filter(
**filter_kwargs
).order_by(f'-{left}')[0].id
).order_by(f'-{left}')[0].pk

except IndexError:
grandparent_id = None

if grandparent_id != parent.id:
if grandparent_id != parent.pk:
parent = changelist.model(pk=grandparent_id)

setattr(parent, self.UPPER_LEVEL_MODEL_ATTR, True)
Expand Down

0 comments on commit 5bd7550

Please sign in to comment.