Skip to content

Commit

Permalink
Added a model-fields task to the example app, to test the MODEL_LABEL…
Browse files Browse the repository at this point in the history
… type.
  • Loading branch information
Zachary Voase committed Dec 27, 2009
1 parent 0fdcda3 commit b3cba79
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/example/echoapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,19 @@ def app_path(args):
print args.app.__file__[:-1]
else:
print args.app.__file__


@command
@argument('model', type=MODEL_LABEL)
def model_fields(args):
"""Print all the fields on a specified model."""

justify = 1
table = []
for field in args.model._meta.fields:
justify = max(justify, len(field.name))
table.append((field.name, field.db_type()))

for name, db_type in table:
print (name + ':').ljust(justify + 1) + '\t' + db_type

0 comments on commit b3cba79

Please sign in to comment.