Created
March 27, 2014 23:17
-
-
Save schinckel/9821292 to your computer and use it in GitHub Desktop.
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
from django.views.generic.base import View | |
def get_class(func): | |
if not getattr(func, 'func_closure', None): | |
return | |
for closure in func.func_closure: | |
contents = closure.cell_contents | |
if not contents: | |
continue | |
if getattr(contents, '__bases__', None) and issubclass(contents, View): | |
return contents | |
result = get_class(contents) | |
if result: | |
return result | |
from django.core.urlresolvers import resolve | |
view = resolve('/path/to/url') | |
get_class(view.func) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment