title: object of type 'WSGIRequest' has no len()
body: <p>I'm running Python3 Django 1.10.3 with current Celery 4.0.0, redis-server stable and rabbitmq. This error happens on both Windows and Linux ubuntu. Google search of this error doesn't turn any conclusive results.</p>
  
  <p>This is the error stack:</p>
  
  <pre><code>Environment:
  
  
  Request Method: POST
  Request URL: https://*/rod/eposta/?cid=17
  
  Django Version: 1.10.3
  Python Version: 3.5.2
  Installed Applications:
  ['django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'vodnik',
   'schedule',
   'djangobower']
  Installed Middleware:
  ['django.middleware.security.SecurityMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware']
  
  
  
  Traceback:
  
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
    39.             response = get_response(request)
  
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _legacy_get_response
    249.             response = self._get_response(request)
  
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
    187.                 response = self.process_exception_by_middleware(e, request)
  
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
    185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
    23.                 return view_func(request, *args, **kwargs)
  
  File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
    23.                 return view_func(request, *args, **kwargs)
  
  File "/var/www/etaborniki/rod/views.py" in eposta
    133.                     email = rodSendEmail.delay(zadeva, clan, sporocilo, request, msgid)
  
  File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py" in delay
    413.         return self.apply_async(args, kwargs)
  
  File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py" in apply_async
    536.             **options
  
  File "/usr/local/lib/python3.5/dist-packages/celery/app/base.py" in send_task
    709.             root_id, parent_id, shadow, chain,
  
  File "/usr/local/lib/python3.5/dist-packages/celery/app/amqp.py" in as_task_v2
    333.             argsrepr = saferepr(args, self.argsrepr_maxsize)
  
  File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in saferepr
    74.         o, maxlen=maxlen, maxlevels=maxlevels, seen=seen
  
  File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in _saferepr
    104.     for token, it in reprstream(stack, seen=seen, maxlevels=maxlevels):
  
  File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in reprstream
    155.         for val in it:
  
  File "/usr/local/lib/python3.5/dist-packages/celery/utils/saferepr.py" in _chainlist
    91.     size = len(it)
  
  Exception Type: TypeError at /rod/eposta/
  Exception Value: object of type 'WSGIRequest' has no len()
  </code></pre>
  
  <p>Code that is causing this error is:</p>
  
  <pre><code>email = rodSendEmail.delay(zadeva, clan, sporocilo, request, msgid)
  </code></pre>
  
  <p>and links to task:</p>
  
  <pre><code>@shared_task
  def rodSendEmail(zadeva, clan, body, request, msgid):
      try:
          now = str(datetime.datetime.utcnow().replace(tzinfo=utc))
          plaintext = get_template('rod/email/clani_msg.txt')
          htmly = get_template('rod/email/clani_msg.html')
          d = Context(
              {
                  'message': body,
                  'rodIme': request.user.info.rod.rodIme,
                  'rodNaslov': request.user.info.rod.rodNaslov,
                  'pattern': 'erod',
              }
          )
          strFrom = str(request.user.get_full_name()) + ' via eRod&lt;erod@ksoft.si&gt;'
          subject, from_email, to, replyto = zadeva, strFrom, [clan.clanEmail], [
              request.user.info.rod.rodEmail]
          text_content = plaintext.render(d)
          html_content = htmly.render(d)
          msg = EmailMultiAlternatives(subject, text_content, from_email, to, reply_to=replyto,
                                       headers={
                                           'X-KSOFT-MSGID': msgid,
                                           'X-KSOFT-REPLYTO': request.user.id,
                                           'X-KSOFT-DATE': now,
                                           'X-KSOFT-ROD': request.user.info.rod.id,
                                       })
          msg.attach_alternative(html_content, "text/html")
  
          msg.mixed_subtype = 'related'
  
          msg.send()
      except smtplib.SMTPException:
          return False
      finally:
          return True
  </code></pre>