Skip to content

Instantly share code, notes, and snippets.

@crccheck
Last active September 24, 2015 05:17
Show Gist options
  • Save crccheck/673062 to your computer and use it in GitHub Desktop.
Save crccheck/673062 to your computer and use it in GitHub Desktop.
Too lazy to figure out what view goes with what url? Me too
# based on http://stackoverflow.com/questions/797773/django-caching-can-it-be-done-pre-emptively
# run this from `manage.py shell`
# if you have ipython, you can do `what_view /some/silly/url/` and remember the leading and trailing slash
from django.core.urlresolvers import resolve
def what_view(url):
try:
(v, foo, params) = resolve(url)
print "View Name: %s Line: %s of %s" % (v.__name__, v.__code__.co_firstlineno, v.__code__.co_filename)
return v, foo, params
except:
raise
# dummy text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment