Questions tagged [django-jsonfield]

162 questions
0
votes
1 answer

Validate Json in Django - Django Rest Framework

I need to validate the following JSON: { "monday": [ //List of MyClass object ], "tuesday": [ //List of MyClass Object ], "wednesday": [ //List of MyClass Object ], ...... } I need to check if it…
Kha Nguyễn
  • 463
  • 1
  • 4
  • 16
0
votes
0 answers

How to populate Django form dynamically with a dictionary of lists and dictionaries?

I've been stuck on this for over a day now and was hoping I could get some help. I've read a bunch of different SO posts and Django docs on forms, formsets, bound and unbound forms, but still cant figure this out. I'm pulling in some data from a…
0
votes
1 answer

Is it better to aggregate all data in a JSONField or use model ForeignKey?

I'm trying to create a business directory in multiple languages. Should I aggregate all the data in one JSONField, or should split it into multiple models, and why. models.py from django.db import models from django.contrib.postgres.fields import…
ghophri
  • 183
  • 1
  • 1
  • 12
0
votes
1 answer

update jsonfields in django model formsets with mongdb

I'm trying to create an editable bootstrap table where each cell represents a json value. I've defined a Django Model with this JSONField (not the Postgres's one) This is my Model: class Extracted_Tables(models.Model): ... content =…
0
votes
1 answer

django rest framework + mariaDB: custom JSONField

Django: v2.1.5 DRF: v3.9.1 mariaDB: v10.3 Hi, I am a DRF newbie and I have been struggling with json field. DRF does not support official json field type working with mariaDB and even though there is a 3rd-party package for mysql(django-mysql) but…
0
votes
0 answers

InternalType of JSONField is shown as TextField

I am a beginner with DJANGO, I am working on a project where one of the models contains a JSONField. In the code at some point i need to detect and process the JSONField only and so I get the internaltype of the fields and if it turns out to be JSON…
Subbu
  • 588
  • 1
  • 7
  • 18
0
votes
1 answer

Django JSONField not receiving cleaned data

I have a very simple model which contains a JSONField: class Thing(models.Model): title = models.CharField(max_length=1024) text = JSONField(default=dict) I've created a custom widget that allows for the input of key-value pairs: class…
Matthew Trevor
  • 14,354
  • 6
  • 37
  • 50
0
votes
0 answers

JSONField reference a model like One to One within the JSON

Stupid question time! :) I don't think this is possible but I need to ask in case I'm wrong. Is it possible to create a one to one relationship to a normal Django model in the JSON of a JSONField? Example: Django Model (Example): class…
James Bellaby
  • 158
  • 14
0
votes
1 answer

Searching for list of values in a Django JSONField

So I've got this model with this JSONField - class Details(models.Model): ref_det = JSONField(null=True, default=dict()) ref_det stores values in this format {'user_id': '2231', 'org_id': 'qpdkm12'} Each object of the model has its ref_det as…
Sidharth Samant
  • 714
  • 8
  • 28
0
votes
1 answer

django JSONField regex

I'm using Django 2.1 and I have model with JSONField(record): { 'fields': [ {'tag': 'x','value': '12345'}, {'tag': 'y','value': '67890'} ] } To query exact 'value' I…
SvartUlv
  • 1
  • 1
0
votes
0 answers

What is the fastest way to order a Django queryset using JSONField?

I have a model which mostly stores data in a JSON field. Its kinda set up as follows: class Record(models.Model): data = JSONField() Usually, the data field has the following format: data = { "name": "Chad", "age": 23 } Now, in a…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
0
votes
1 answer

Django response error 'unicode' object has no attribute '_meta' json

I'm using django 1.11 and i'm getting a tough time in storing a Json response.Here's my views.py code views.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from .models import addinfomodels from django.shortcuts import render,…
0
votes
0 answers

Django JSON field in forms

here's my problem.I'm trying to create product variants which contain attribute values of the selected product. I'm trying to use JSONField to do that but I was wondering how I could dynamically display the fields in the form for creating new…
Fantasmo Clone27
  • 333
  • 1
  • 10
  • 19
0
votes
1 answer

How to remove custom field without breaking Django migrations?

I work on a Django 1.8 project that uses the old django-json-field library. I want to remove the library, update to Django 1.9 and use the native JSONField, but I have migrations that rely on the JSONField from the old library, so I can't remove it.…
Ariel
  • 3,383
  • 4
  • 43
  • 58
0
votes
1 answer

Adapt JSONField to have auto conversion to Decimal

I have model with fields of type: django.contrib.postgres.fields.JSONField and I want have it always deserialized by: json.loads(value, parse_int=decimal.Decimal, parse_float=decimal.Decimal) when accessing objects…
1 2 3
10
11