Skip to content

Commit

Permalink
fix #115 #116 修复无限递归问题
Browse files Browse the repository at this point in the history
  • Loading branch information
newpanjing committed Jul 22, 2019
1 parent 86cd162 commit cdb94c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
django_simpleui.egg-info
dist
7 changes: 5 additions & 2 deletions simpleui/templatetags/simpletags.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ def get_model_fields(model, base=None):
list.append(('{}__{}'.format(base, f.name), label))
else:
list.append((f.name, label))
if isinstance(f, ForeignKey):
list.extend(get_model_fields(f.related_model, f.name))

return list

Expand All @@ -391,8 +389,13 @@ def get_model_fields(model, base=None):
def search_placeholder(context):
cl = context.get('cl')

# 取消递归,只获取2级
fields = get_model_fields(cl.model)

for f in cl.model._meta.fields:
if isinstance(f, ForeignKey):
fields.extend(get_model_fields(f.related_model, f.name))

verboses = []

for s in cl.search_fields:
Expand Down

0 comments on commit cdb94c3

Please sign in to comment.