Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sfreytag/1333742 to your computer and use it in GitHub Desktop.
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.
"""
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