Created
January 5, 2016 15:14
-
-
Save alxscms/9aa81fa53bcf4018bc62 to your computer and use it in GitHub Desktop.
Print all attributes of a django model with colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_model(object): | |
print "\033[96m<{0}>\033[0m".format(wp.__class__.__name__) | |
for field in object._meta.fields: | |
if field.value_to_string(object) != 'None' and field.value_to_string(object) != '': | |
print "\033[94m{0:30}\033[0m \033[93m{1}\033[0m".format(field.name, field.value_to_string(object)) | |
else: | |
print "{0:30} {1}".format(field.name, field.value_to_string(object)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment