Skip to content

Commit

Permalink
Merge branch 'rapilabs-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Apr 3, 2015
2 parents d7e7493 + 5bb932f commit df4c06c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions django_admin_generator/management/commands/admin_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def name(self):
def _process_many_to_many(self, meta):
raw_id_threshold = self.raw_id_threshold
for field in meta.local_many_to_many:
related_objects = field.related.parent_model.objects.all()
related_model = getattr(field.related, 'related_model',
field.related.model)
related_objects = related_model.objects.all()
if(related_objects[:raw_id_threshold].count() < raw_id_threshold):
yield field.name

Expand All @@ -174,7 +176,9 @@ def _process_foreign_key(self, field):
raw_id_threshold = self.raw_id_threshold
list_filter_threshold = self.list_filter_threshold
max_count = max(list_filter_threshold, raw_id_threshold)
related_count = field.related.parent_model.objects.all()
related_model = getattr(field.related, 'related_model',
field.related.model)
related_count = related_model.objects.all()
related_count = related_count[:max_count].count()

if related_count >= raw_id_threshold:
Expand Down
2 changes: 1 addition & 1 deletion test_project/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")

from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application # NOQA
application = get_wsgi_application()

0 comments on commit df4c06c

Please sign in to comment.