from django import template

register = template.Library()

"""
Copied these from django/contrib/admin/templates/templatetags/admin_urls.
These are utility functions for generating urls to admin pages.
I want to extend the standard /admin url to always include the current project,
designated by /site/<projectname>/admin. 
"""

@register.filter
def project_admin_urlname(value, arg):    
    return 'projectadmin:%s_%s_%s' % (value.app_label, value.modal_name, arg)

from django import template

register = template.Library()

"""
Copied these from django/contrib/admin/templates/templatetags/admin_urls.
These are utility functions for generating urls to admin pages.
I want to extend the standard /admin url to always include the current project,
designated by /site/<projectname>/admin. 
"""

@register.filter
def project_admin_urlname(value, arg):    
    return 'projectadmin:%s_%s_%s' % (value.app_label, value.model_name, arg)

Update for function name change in Django 1.8