Questions tagged [jsonfield]
28 questions
0
votes
1 answer
Django annotate double nested key in JSONField
My JSONField contains data like this:
class Car(models.Model):
data = JSONField()
Car.objects.first().data
{
u'colors': [
{u'color_id': u'1', u'source': u'Manufacturer 3'},
{u'color_id': u'2', u'source': u'Manufacturer 2'},
…

Ray Tango
- 107
- 9
0
votes
0 answers
mysql JSON field sort by field in array of objects (sequelize)
I have mysql db with next fields
id - number
name - string
type - string enum (admin, user, guest)
parentTransactionId - number
payDetails - JSON field, array of objects
examples of payDetails:
[{"type": "stripe_fee", "amount": 1.09, "currency":…

Jackson
- 884
- 2
- 13
- 22
0
votes
0 answers
ValidationError: [u'Enter valid JSON']: Can load DJANGO JSON field in my local machine but not in remote production server
I have a field of type JSONField that basically contains this structure:
[{u'date': u'2021-11-24T13:51:47', u'text': u'todayone'},
{u'date': u'2021-11-24T13:52:38', u'text': u'todaytwo'},
{u'date': u'2021-11-24T13:53:26', u'text':…

Victor Martinez
- 107
- 1
- 9
0
votes
0 answers
Why my Model JSON/list attribute in Django sometimes misses data?
I'm building a Django project that has to do with generating math/science problems for teachers and students.
The project works fine for some time but when I run it on the browser (with the views all set up) it sometimes get errors that I cant…

Franklin Santos
- 23
- 3
0
votes
0 answers
How to make Django modifiy JSONField value effictively
With MySQL8.0.25 as database backend, I make Django ORM to update the following JSONField value
{
"01-task1": {"data":"huge data here"}
}
just add a new element , "02-testing": {}
but I got the following sql log
(0.000) UPDATE…

Jcyrss
- 1,513
- 3
- 19
- 31
0
votes
1 answer
look up the value in jsonfield of django
The model contains a jsonfield:
class MyModel(Model):
test_result = JSONField()
the data to be handled is dynamic, {'test1':100,'test2':95,'test9':80,...} , { 'test2':60, 'test3':80,'test6':70,... } ...
I want to find all the test results of…

user9071001
- 36
- 2
0
votes
1 answer
Django djsonfield Decimal stored as string in expressions
I have a JSONField with some financial data. I cannot store it as a float, because I need precision, so I store it as a string.
My model looks like this
class Finance(models.Model)
bill_data = JSONField(
verbose_name=_("Bill data"),
…

alis01
- 169
- 1
- 3
- 11
0
votes
1 answer
Annotate JSONField on-the-fly and retrieve keys via values
I annotate a JSONField on-the-fly like this. Since this is not a field of a model I think the model is not relevant. This example should be valid for any queryset.
>>> from django.db.models import F, Func, JSONField, Value
>>> queryset =…

Stefan_EOX
- 1,279
- 1
- 16
- 35
0
votes
1 answer
Mysql json fields - filter inside by paramter
I have in mysql json field with the values:
{"a": true, "b":true, "c":false, "d":true}
I want to retrieve in SQL, for each row, only the keys and values that are true.
For example in the row:
{"a": true, "b":true, "c":false, "d":true}
the result…

aspp
- 21
- 2
0
votes
0 answers
Inconsistent "contains" filter behaviour for jsonfield mysql/sqlite
I'm getting inconsistent results depending on the backend database when using jsonfield "contains" queries.
from polymorphic.models import PolymorphicModel
import jsonfield
class Action(PolymorphicModel):
new_object =…

Martijn
- 1
- 3
0
votes
1 answer
Django new field "JSONField" error - Column does not exist
I created a dummy project just to test the new field JSONField of Django but the column doesn't not appear to be created (I am using Postgresql).
class Author(models.Model):
name = models.CharField(max_length=50)
description =…

Andre
- 1
- 1
0
votes
2 answers
How can I reshape this nested JSON data?
This is essentially what the payload looks like from my API. I'd like to reshape the data so I can dynamically display the data on the frontend without hard coding things like column names. For what it's worth I'm using DRF, axios, and react-redux.…

DerC
- 1
- 2
-1
votes
1 answer
peewee filter with BinaryJSONField?
class Modex(baseModal):
sdgdList = BinaryJSONField(verbose_name="sdgdList",null=True,)
sdgdList Data:
[{"x": "1", "cgs": "11.00", "gbxz": "A", "gdmc": "aaa", "zjqk": "0.48", "zzgs": "0.18", "zjqkCss": "red", "gdblockid": "10",}, {"x": "2",…

ccc
- 3
- 2