def customer(request):
 msg = u"The request object does not contain a customer. Edit your MIDDLEWARE_CLASSES setting to insert 'shop.middlerware.CustomerMiddleware'."
 assert hasattr(request, u'customer'), msg
 context = {u'customer': request.customer, u'site_header': app_settings.APP_LABEL.capitalize()}
 if request.user.is_staff:
  try:
   context.update(customer=CustomerModel.objects.get(pk=request.session[u'emulate_user_id']))
  except (CustomerModel.DoesNotExist, KeyError, AttributeError):
   pass
 return context

def customer ( request ) : msg = u"The request object does not contain a customer. Edit your MIDDLEWARE_CLASSES setting to insert 'shop.middlerware.CustomerMiddleware'." assert hasattr ( request , u'customer' ) , msg context = { u'customer' : request . customer , u'site_header' : app_settings . APP_LABEL . capitalize ( ) } if request . user . is_staff : try : context . update ( customer = CustomerModel . objects . get ( pk = request . session [ u'emulate_user_id' ] ) ) except ( CustomerModel . DoesNotExist , KeyError , AttributeError ) : pass return context
add the customer to the requestcontext .