Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

changed list filter threshold to 25

  • Loading branch information...
commit 21ef5fc61a6f5d55b33be398860afd8b4aa47c6c 1 parent 7fcdc0c
Rick van Hattem authored

Showing 1 changed file with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. +12 4 django_utils/management/commands/admin_autogen.py
16 django_utils/management/commands/admin_autogen.py
@@ -25,6 +25,8 @@
25 25 'slug': ('name',)
26 26 }
27 27
  28 +LIST_FILTER_TRESHOLD = 25
  29 +RAW_ID_THRESHOLD = 100
28 30
29 31 class Command(BaseCommand):
30 32
@@ -85,11 +87,17 @@ def handle_app(self, app, **options):
85 87
86 88 if isinstance(field, LIST_FILTER):
87 89 if isinstance(field, models.ForeignKey):
88   - if(field.related.parent_model.objects.all()[:100]
89   - .count() <= 100):
90   - model_dict['list_filter'].append(field.name)
91   - else:
  90 + related_count = (field.related.parent_model.objects
  91 + .all()
  92 + [:max(LIST_FILTER_TRESHOLD, RAW_ID_THRESHOLD)]
  93 + .count()
  94 + )
  95 +
  96 + if related_count >= RAW_ID_THRESHOLD:
92 97 model_dict['raw_id_fields'].append(field.name)
  98 +
  99 + if related_count >= LIST_FILTER_TRESHOLD:
  100 + model_dict['list_filter'].append(field.name)
93 101 else:
94 102 model_dict['list_filter'].append(field.name)
95 103

0 comments on commit 21ef5fc

Please sign in to comment.
Something went wrong with that request. Please try again.