@register.render_tag
def set_model_permissions(context, token):
 model = context[token.split_contents()[1]]
 opts = model._meta
 perm_name = ((opts.app_label + u'.%s_') + opts.object_name.lower())
 request = context[u'request']
 setattr(model, u'perms', {})
 for perm_type in (u'add', u'change', u'delete'):
  model.perms[perm_type] = request.user.has_perm((perm_name % perm_type))
 return u''

@ register . render_tag def set_model_permissions ( context , token ) : model = context [ token . split_contents ( ) [ 1 ] ] opts = model . _meta perm_name = ( ( opts . app_label + u'.%s_' ) + opts . object_name . lower ( ) ) request = context [ u'request' ] setattr ( model , u'perms' , { } ) for perm_type in ( u'add' , u'change' , u'delete' ) : model . perms [ perm_type ] = request . user . has_perm ( ( perm_name % perm_type ) ) return u''
assigns a permissions dict to the given model .