def populate_xheaders(request, response, model, object_id):
 from django.conf import settings
 if ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS) or (hasattr(request, 'user') and request.user.is_authenticated() and request.user.is_staff)):
  response['X-Object-Type'] = ('%s.%s' % (model._meta.app_label, model._meta.object_name.lower()))
  response['X-Object-Id'] = str(object_id)

def populate_xheaders ( request , response , model , object_id ) : from django . conf import settings if ( ( request . META . get ( 'REMOTE_ADDR' ) in settings . INTERNAL_IPS ) or ( hasattr ( request , 'user' ) and request . user . is_authenticated ( ) and request . user . is_staff ) ) : response [ 'X-Object-Type' ] = ( '%s.%s' % ( model . _meta . app_label , model . _meta . object_name . lower ( ) ) ) response [ 'X-Object-Id' ] = str ( object_id )
adds the "x-object-type" and "x-object-id" headers to the given httpresponse according to the given model and object_id -- but only if the given httprequest object has an ip address within the internal_ips setting or if the request is from a logged in staff member .