@register.inclusion_tag(u'generic/includes/rating.html', takes_context=True)
def rating_for(context, obj):
 context[u'rating_object'] = context[u'rating_obj'] = obj
 context[u'rating_form'] = RatingForm(context[u'request'], obj)
 ratings = context[u'request'].COOKIES.get(u'mezzanine-rating', u'')
 rating_string = (u'%s.%s' % (obj._meta, obj.pk))
 context[u'rated'] = (rating_string in ratings)
 rating_name = obj.get_ratingfield_name()
 for f in (u'average', u'count', u'sum'):
  context[(u'rating_' + f)] = getattr(obj, (u'%s_%s' % (rating_name, f)))
 return context

@ register . inclusion_tag ( u'generic/includes/rating.html' , takes_context = True ) def rating_for ( context , obj ) : context [ u'rating_object' ] = context [ u'rating_obj' ] = obj context [ u'rating_form' ] = RatingForm ( context [ u'request' ] , obj ) ratings = context [ u'request' ] . COOKIES . get ( u'mezzanine-rating' , u'' ) rating_string = ( u'%s.%s' % ( obj . _meta , obj . pk ) ) context [ u'rated' ] = ( rating_string in ratings ) rating_name = obj . get_ratingfield_name ( ) for f in ( u'average' , u'count' , u'sum' ) : context [ ( u'rating_' + f ) ] = getattr ( obj , ( u'%s_%s' % ( rating_name , f ) ) ) return context
provides a generic context variable name for the object that ratings are being rendered for .