Browse files

minor refactor

  • Loading branch information...
1 parent eaaf608 commit a234b5f1f9c1ebabe0d98c8a2f0828a3576e6bd5 @chrisclark chrisclark committed Feb 9, 2014
Showing with 7 additions and 2 deletions.
  1. +7 −2 explorer/utils.py
View
9 explorer/utils.py
@@ -77,20 +77,25 @@ def schema_info():
ret.append((
friendly_model,
model._meta.db_table,
- [(f.get_attname_column()[1], f.get_internal_type()) for f in model._meta.fields]
+ [_format_field(f) for f in model._meta.fields]
))
#Do the same thing for many_to_many fields. These don't show up in the field list of the model
#because they are stored as separate "through" relations and have their own tables
ret += [(
friendly_model,
m2m.rel.through._meta.db_table,
- [(f.get_attname_column()[1], f.get_internal_type()) for f in m2m.rel.through._meta.fields]
+ [_format_field(f) for f in m2m.rel.through._meta.fields]
) for m2m in model._meta.many_to_many]
return sorted(ret, key=lambda t: t[1]) # sort by table name
+def _format_field(field):
+ return (field.get_attname_column()[1], field.get_internal_type())
+
+
+
def param(name):
return "%s%s%s" % (EXPLORER_PARAM_TOKEN, name, EXPLORER_PARAM_TOKEN)

0 comments on commit a234b5f

Please sign in to comment.