From b3cba79babf14df90a5668d2dfcecd24d39c5e40 Mon Sep 17 00:00:00 2001 From: Zachary Voase Date: Sun, 27 Dec 2009 04:52:10 +0000 Subject: [PATCH] Added a model-fields task to the example app, to test the MODEL_LABEL type. --- test/example/echoapp/commands.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/example/echoapp/commands.py b/test/example/echoapp/commands.py index f84ff95..a68cf97 100644 --- a/test/example/echoapp/commands.py +++ b/test/example/echoapp/commands.py @@ -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 +