#27886: Django contrib.postgres JSONField adds additonal quotes to a dictionary. --------------------------------------------+------------------------ Reporter: pypetey | Owner: (none) Type: Uncategorized | Status: new Component: contrib.postgres | Version: 1.10 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | --------------------------------------------+------------------------ I have installed django-channels and django-cq library for async/background tasks.
JSONField from django.contrib.postgres.fields is used on the model. And when I assign to function to do async stuff the django-cq library would be creating a task in the database. The code is relatively simple - it creates a Task object in the database and it uses JSONField from contrib.postgres on signature field. sig = to_signature(func, args, kwargs) if parent is None and previous: parent = previous.parent task = Task.objects.create(signature={}, parent=parent, previous=previous, **kw) When I access task objcect directly then I get task.__dict__ Out[2]: {'_parent_cache': None, '_previous_cache': None, '_state': <django.db.models.base.ModelState at 0x83fcfd0>, '_uncommitted_filefields': [], 'at_risk': 'N', 'details': {}, 'finished': None, 'force_chain': False, 'id': UUID('40e62169-f743-47a1-95ea-ebe57acc9f38'), 'last_retry': None, 'parent_id': None, 'previous_id': None, 'result_expiry': None, 'result_ttl': 1800, 'retries': 0, 'signature': {'args': (), 'func_name': 'apps.accounts.consumers.send_email', 'kwargs': {}}, 'started': None, 'status': 'P', 'submitted': datetime.datetime(2017, 2, 28, 13, 47, 46, 329656, tzinfo=<UTC>), 'waiting_on_id': None} However, when I do refresh the instsance from db by doing task.refresh_from_db() and then task.__dict__ I will receive this variation which has completely different quoting on JSONField fields (signature and details) Out[4]: {'_state': <django.db.models.base.ModelState at 0x83fcfd0>, '_uncommitted_filefields': [], 'at_risk': 'N', 'details': '{}', 'finished': None, 'force_chain': False, 'id': UUID('40e62169-f743-47a1-95ea-ebe57acc9f38'), 'last_retry': None, 'parent_id': None, 'previous_id': None, 'result_expiry': None, 'result_ttl': 1800, 'retries': 0, 'signature': '{"args": [], "kwargs": {}, "func_name": "apps.accounts.consumers.send_email"}', 'started': None, 'status': 'P', 'submitted': datetime.datetime(2017, 2, 28, 13, 47, 46, 329656, tzinfo=<UTC>), 'waiting_on_id': None} What could be root cause of the problem? Is it a bug in django? I use windows 10 pro, postgres 95, python 3.5 32bit This ticket might be related with: https://code.djangoproject.com/ticket/25532#no2 -- Ticket URL: <https://code.djangoproject.com/ticket/27886> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.6096db44505dd2835a8812560655446c%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.