Skip to content

Instantly share code, notes, and snippets.

@yangyubo
Created July 20, 2012 02:38
Show Gist options
  • Save yangyubo/3148316 to your computer and use it in GitHub Desktop.
Save yangyubo/3148316 to your computer and use it in GitHub Desktop.
Get object's full model name, formatted as "app_label.module_name"
# django tempatetag
# django version >= 1.4 is required
@register.assignment_tag
def get_full_modelname(object):
"""
usage:
{% get_full_modelname object as modelname_var %}
"""
opts = object._meta
return '%s.%s'%(opts.app_label, opts.module_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment