#32807: JSONField.bound_data raises TypeError when data is None
-------------------------------------+-------------------------------------
     Reporter:  Dan Strokirk         |                    Owner:  Dan
                                     |  Strokirk
         Type:  Bug                  |                   Status:  closed
    Component:  Forms                |                  Version:  3.2
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  JSONField            |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Timothy Hobbs):

 Hi, was this fixed already in the release Django 3.2.7? I'm getting this
 backtrace on Django 3.2.7 when running admin smoke tests and the backtrace
 doesn't touch my code at all, making it a bit tricky to debug:

 {{{
 ======================================================================
 ERROR: test_change_post (apps.aklub.tests.test_admin.AdminSmokeTest)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/klub-v/venv/src/django-admin-smoke-
 tests-2/django_admin_smoke_tests/tests.py", line 31, in test_deco
     fn(self, model, model_admin)
   File "/klub-v/venv/src/django-admin-smoke-
 tests-2/django_admin_smoke_tests/tests.py", line 307, in test_change_post
     response.render()
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/response.py", line 105, in render
     self.content = self.rendered_content
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/response.py", line 83, in rendered_content
     return template.render(context, self._request)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/backends/django.py", line 61, in render
     return self.template.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 170, in render
     return self._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 150, in render
     return compiled_parent._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 62, in render
     result = block.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 62, in render
     result = block.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/defaulttags.py", line 211, in render
     nodelist.append(node.render_annotated(context))
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/loader_tags.py", line 195, in render
     return template.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 172, in render
     return self._render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/test/utils.py",
 line 100, in instrumented_test_render
     return self.nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/defaulttags.py", line 211, in render
     nodelist.append(node.render_annotated(context))
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/defaulttags.py", line 211, in render
     nodelist.append(node.render_annotated(context))
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/defaulttags.py", line 312, in render
     return nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/template/defaulttags.py", line 312, in render
     return nodelist.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 938, in render
     bit = node.render_annotated(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 905, in render_annotated
     return self.render(context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 994, in render
     return render_value_in_context(output, context)
   File "/klub-v/venv/lib/python3.8/site-packages/django/template/base.py",
 line 973, in render_value_in_context
     value = str(value)
   File "/klub-v/venv/lib/python3.8/site-packages/django/utils/html.py",
 line 376, in <lambda>
     klass.__str__ = lambda self: mark_safe(klass_str(self))
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/forms/boundfield.py", line 34, in __str__
     return self.as_widget()
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/forms/boundfield.py", line 95, in as_widget
     value=self.value(),
   File "/klub-v/venv/lib/python3.8/site-
 packages/django/forms/boundfield.py", line 130, in value
     data = self.field.bound_data(self.data, data)
   File "/klub-v/venv/lib/python3.8/site-packages/django/forms/fields.py",
 line 1265, in bound_data
     return json.loads(data, cls=self.decoder)
   File "/usr/local/lib/python3.8/json/__init__.py", line 341, in loads
     raise TypeError(f'the JSON object must be str, bytes or bytearray, '
 TypeError: the JSON object must be str, bytes or bytearray, not NoneType
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32807#comment:9>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.d5dc9116de41a24a5680b75718546899%40djangoproject.com.

Reply via email to