#26041: Flattening a Context object can fail
---------------------------------+--------------------
     Reporter:  jaddison         |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Template system  |    Version:  1.9
     Severity:  Normal           |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+--------------------
 I believe this is related to https://code.djangoproject.com/ticket/24765.

 Sample project attached, requires django-contrib-comments. Steps:

 1. extract sample project
 2. pip install requirements in virtualenv
 3. run migrations
 4. run runserver
 5. view http://localhost:8000/1/

 Note that 'master' of django-contrib-comments uses `flatten` instead of
 its v1.6.2 (which is what's on PyPi) current code which performs the same
 functionality. It fails the same way in master and v1.6.2.

 Here is the traceback when using django-contrib-comments 'master' branch:

 {{{

 Environment:


 Request Method: GET
 Request URL: http://localhost:8000/1/

 Django Version: 1.9.1
 Python Version: 2.7.10
 Installed Applications:
 ['django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'django.contrib.sites',
  'django_comments',
  'blog']
 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']


 Template error:
 In template
 /Users/jaddison/projects/djangocontext/blog/templates/blog/blogitem.html,
 error at line 0
    dictionary update sequence element #0 has length 3; 2 is required   1 :
 {% load blogtags comments %}
    2 : <!DOCTYPE html>
    3 : <html lang="en">
    4 : <head>
    5 :     <meta charset="UTF-8">
    6 :     <title>Title</title>
    7 : </head>
    8 : <body>
    9 : {{ item.text }}
    10 : {% do_nothing_special_tag %}


 Traceback:

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/core/handlers/base.py" in get_response
   149.                     response =
 self.process_exception_by_middleware(e, request)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/core/handlers/base.py" in get_response
   147.                     response = wrapped_callback(request,
 *callback_args, **callback_kwargs)

 File "/Users/jaddison/projects/djangocontext/blog/views.py" in view_item
   8.     return render(request, 'blog/blogitem.html', {'item':item})

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/shortcuts.py" in render
   67.             template_name, context, request=request, using=using)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/loader.py" in render_to_string
   97.         return template.render(context, request)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/backends/django.py" in render
   95.             return self.template.render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render
   206.                     return self._render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in _render
   197.         return self.nodelist.render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render
   988.                 bit = node.render_annotated(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render_annotated
   955.             return self.render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/library.py" in render
   243.         return t.render(new_context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render
   208.                 return self._render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in _render
   197.         return self.nodelist.render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render
   988.                 bit = node.render_annotated(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/base.py" in render_annotated
   955.             return self.render(context)

 File "/Users/jaddison/.virtualenvs/djangocontext/src/django-
 comments/django_comments/templatetags/comments.py" in render
   181.             context_dict = context.flatten()

 File "/Users/jaddison/.virtualenvs/djangocontext/lib/python2.7/site-
 packages/django/template/context.py" in flatten
   120.             flat.update(d)

 Exception Type: ValueError at /1/
 Exception Value: dictionary update sequence element #0 has length 3; 2 is
 required

 }}}

 Definitely has to do with running `render_comment_form` from within a
 custom `inclusion_tag` template.

--
Ticket URL: <https://code.djangoproject.com/ticket/26041>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.1a9c39a4215032609042f581638e4e84%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to