Questions tagged [django-jsonfield]
162 questions
1
vote
2 answers
JSON field for model Django 3.0a
I'm using Django 3.0a with Python 3.7
I had searched a lot for a JSON field that works with the Data base sqlite and other (I know that Django > 2.2 support JSONfield for postgres)
Now I had tried this libraries:…

Allon
- 55
- 4
1
vote
1 answer
Django filter is not using the index on Postgresql JSONField
I have a Django model that contains a PostgreSQL jsonb field:
class SocialUser(models.Model):
id = models.BigIntegerField(primary_key=True)
data = JSONField(blank=True, null=True, db_index=True)
The data field contains a username attribute.…

onurmatik
- 5,105
- 7
- 42
- 67
1
vote
2 answers
django JSONField contains greater than
I have the model Item with JSON field
metadata = JSONField(null=True)
sample content:
[{"value": 50, name: "other"}, {"value": 60, name: "other2"}]
How can I query all rows where exists a "value" larger than 50?
I…

user3599803
- 6,435
- 17
- 69
- 130
1
vote
2 answers
What is the difference between annotations and regular lookups using Django's JSONField?
You can query Django's JSONField, either by direct lookup, or by using annotations. Now I realize if you annotate a field, you can all sorts of complex queries, but for the very basic query, which one is actually the preferred method?
Example: Lets…

darkhorse
- 8,192
- 21
- 72
- 148
1
vote
3 answers
django malformed array literal:
I have a little problem:
I have this model:
class myModel(models.Model):
myField =JSONField()
I want to update this field:
data={'rda': {'punti': 0, 'rank': 1, 'pos': 'eq'}}
a =myModel()
a.myField=data
a.save()
but I have this…

marcantonio sofia
- 107
- 2
- 13
1
vote
1 answer
Ordering Django queryset using attributes of a JSONField, provided the attribute is not present everywhere
This is a very complex question, so let me explain. I have a model called Person which stores most of its data in a JSONField.
class Person(models.Model):
data = JSONField()
Now, the data field is usually in the the following format:
{"name" :…

darkhorse
- 8,192
- 21
- 72
- 148
1
vote
1 answer
Ordering Django querysets using a JSONField's properties
I have a model that kinda looks like this:
class Person(models.Model):
data = JSONField()
The data field has 2 properties, name, and age. Now, lets say I want to get a paginated queryset (each page containing 20 people), with a filter where age…

darkhorse
- 8,192
- 21
- 72
- 148
1
vote
1 answer
Django allauth Social application extra data
so I have set up Django allauth on my Django project and connected to Instagram,
when doing so I have now on my admin site Social accounts category with my account registers, all good so far
on the lower page, I can see a field called extra…

Nerii Doron
- 43
- 7
1
vote
1 answer
Issue while saving object to database because model contains jsonfield sqlite3 django
I had a really tough time to get fix this issue please help if you know this. I have a project on django, It contain model with two fields, one is of type foreign key and other one is jsonfield. When it goes to save object in database, it doesn't…

Rohit Mandhan
- 89
- 2
- 13
1
vote
1 answer
JSONField, Django, PostgreSQL, retrieving data
I have a JSONField which seems to be successfully storing a JSON as a string in my database.
How do I retrieve this data as a dictionary?
class Package:
node = JSONField(null=True, blank=True)
packageInstance =…

GeneralBear
- 1,011
- 3
- 11
- 35
1
vote
0 answers
How to filter based on a nested Django JSONField?
I have a json field for a model in my Django app that typically has nested json in it. I read that to filter on a JSONfield, you would use contains on the filter for whatever value you are looking for, but I'm not getting any results back even…

TJB
- 3,706
- 9
- 51
- 102
1
vote
0 answers
How to filter objects in django based on json field where a key is list and based on number of list items mathched for each object?
I have a an object named canditade.
class Candidate(models.Model):
name = models.CharField(max_length=64)
skills = models.JSONField()
I have created objects like this
Candidate.objects.create(name='mark',skills={'list':{'name':'python'},
…

Arbaz Hundekar
- 78
- 8
1
vote
2 answers
django - aggregate json field specific keys and order by the aggregation
I have a model with the a field data of type JSONField from django.contrib.postgres.fields. The json structure is like so:
{'aa': 1, 'bb': 2, 'cc': 4}
I want to aggregate the sums of the aa and cc keys - so in this case, it will be 5. Also - i…

Mr T.
- 4,278
- 9
- 44
- 61
1
vote
1 answer
Update data in a JsonField django
I want to update a json object that is in a jsonfield in django, i am having a problem updating the data.
My model looks like this
https://codeshare.io/Gbeonj
My json looks like this
https://codeshare.io/5obDPX
so basicly the json has wrong data ,…

Edward Okech
- 151
- 3
- 9
1
vote
2 answers
SELECT on JSONField with Django
My application is heavily reliant on APIs that unpredictably make changes to the way they return data. For this reason, I've chosen to use PSQL and JSONFields with Django.
I've seen plenty of examples/docs on how to filter by values in a JSONField,…

J__
- 636
- 6
- 20