Created
November 2, 2011 14:15
-
-
Save sfreytag/1333742 to your computer and use it in GitHub Desktop.
Generate a http://yuml.me definition of Django's class-based views to get a nice class diagram of those views.
This file contains hidden or 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
""" | |
Generate a http://yuml.me definition of Django's class-based views to get a | |
nice class diagram of those views. | |
""" | |
# This runs as a script, but in my Django project root, so import the settings | |
import settings | |
import inspect | |
import django.views.generic.list as list_views | |
import django.views.generic.edit as edit_views | |
import django.views.generic.detail as detail_views | |
import django.views.generic.base as base_views | |
def print_classes_in_module(module): | |
for name, obj in inspect.getmembers(module, inspect.isclass): | |
for attr, val in inspect.getmembers(obj): | |
if val == module.__name__: | |
for base in obj.__bases__: | |
print "[%s]^[%s]" % (name, base.__name__) | |
print_classes_in_module(list_views) | |
print_classes_in_module(edit_views) | |
print_classes_in_module(detail_views) | |
print_classes_in_module(base_views) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment