Questions tagged [django-jsonfield]

162 questions
0
votes
2 answers

Django 1.10 Postgres JSONField extract specific keys

I have a Postgres based JSONField in my model. class MyModel(models.Model): data = JSONField(default=dict) The JSON sample is like: { 'key1': 'val1', 'key2': 'val2' } I have multiple objects of the model, let's say ~50. I am trying to…
Ishan
  • 3,303
  • 5
  • 29
  • 47
0
votes
1 answer

In Django ORM, how does one get_or_create for values in JSONField?

I am having a Django model like: class Subscription(models.Model): data = JSONField(default=dict) I want to do something like this: data = {"product_id": 123, "available": False} subscription, new =…
0
votes
1 answer

django filter postgres json field variable not defined

I am new to working with Django and postgres JSONFields. Using Django 1.11.1 The following view reports a name 'snapshot__timestamp' is not defined Model: class Snapshot(models.Model): id = PGUUIDField(primary_key=True) snapshot =…
Michaela Ervin
  • 702
  • 8
  • 25
0
votes
3 answers

django REST framework does not work show new fields in a model

I am new to Django, I am trying to achieve a Product Lookup module fetches data from MySQL responds to GET request. Here is my model models.py class CNF_BRAND(models.Model): COMPANY_NAME = models.CharField(max_length=255) BRAND_NAME =…
0
votes
2 answers

Appending an item to a Django JsonField - Getting a TypeError

In my models.py, I have the following code: from __future__ import unicode_literals from django.db import models from django.contrib.postgres.fields import JSONField import json class Table(models.Model): name =…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
0
votes
1 answer

Custom JSONField in Django

I am trying to implement a custom JSON Field for my models using Django + MySQL. This is what my models.py looks like: from __future__ import unicode_literals from django.db import models from django.db import models from…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
0
votes
1 answer

How to render characters in a textfield correctly in a JSON template

I have created a Django application with a model with a TextField. When I use the admin interface, I can populate the TextField as such below: However, when I render it in JSON using a template I get the following on my browser. I.e. it cannot…
0
votes
1 answer

How to process a request containing a list of JSON objects

I am working on REST API in Django. Here is my view: if request.method == 'GET': print "In get*****************" print "Request",request queryset = Beer.objects.all() serializer = BeerSerializer(queryset, many=True) return…
0
votes
0 answers

Django rest framework outputs JSONField with unicode prefix

In my api the output of JSONField looks like so: "custom_content": "{u'key': u'value', u'hej': 1.992}", Should be: "custom_content": {"key": "value", "hej": 1.992}, I use djangorestframework==3.1.1, jsonfield==1.0.3, Django==1.7.4, python…
Christoffer
  • 7,436
  • 4
  • 40
  • 42
-1
votes
3 answers

Django loop through json object

How to loop through a JSON object in Django template? JSON: "data": { "node-A": { "test1A": "val1A", "test2A": "val2A", "progress": { "conf": "conf123A" "loc": "loc123A" }, "test3A": "val3A" }, …
rens
  • 89
  • 2
  • 9
-1
votes
1 answer

How can I storage data inputted on my localHost page (with Django) in .txt/.json files?

I tried this and Django still working, but the .json files don't appear on my rute. This is models.py (Django script) from django.db import models class Pizza(models.Model): """A pizza in a pizzeria""" …
Padax39
  • 3
  • 1
-1
votes
1 answer

How to install JSONFields properly?

I just wanted to upload my django project on digitalocean, but ran into multiple problems, of which I can not solve the last one. I am using a restframework. After getting an error, that there is No module named rest_framework.views I installed…
Marcel
  • 72
  • 1
  • 3
  • 11
1 2 3
10
11