Questions tagged [django-jsonfield]

162 questions
0
votes
0 answers

Django differ JSONField values between lists and objects

I am using django 3.2 with Postgres as DB. I have a model with JSONField: class MyModel(models.Model): data = models.JSONField(default=dict, blank=True) In database there are a lot of records in this table and some data have JSON values as…
belek
  • 907
  • 9
  • 35
0
votes
0 answers

How to append a list in a dict from a JSONField in django

I want to use get_or_create() to search for an object. If it doesn't exist, it gets created. If it does exist, I want to update its metadata which is stored as a JSONFeild. obj, created = Customer.objects.get_or_create( first_name="John", …
AlZ
  • 1
  • 2
0
votes
0 answers

How to append a list inside of a dict from a JSONField in django

I want to use get_or_create() to search for an object. If it doesn't exist, it gets created. If it does exist, I want to update its metadata which is stored as a JSONFeild. Lets say we have this class and object: Class Customer(models.Model): …
AlZ
  • 1
  • 2
0
votes
1 answer

Django convert CBV to json

I have this CBV class Ansicht(AdminStaffRequiredMixin, LoginRequiredMixin, DetailView): model = User template_name = 'SCHUK/Ansicht.html' context_object_name = 'Ansicht' Im using _set to display all users data to staff. But I need…
user19711010
0
votes
1 answer

Postgres query with JSONField on array

I am new to Postgres, and try to build a SQL query that can retrieve a Key/Value dictionary pair in an array [] from table table_b and use it in the WHERE clause on finding matching tag_name and tag_value returning the object_uuid The original tags…
samxiao
  • 2,587
  • 5
  • 38
  • 59
0
votes
1 answer

django-jsonforms how to limit how many fields can add from object properties collapsable?

Is there a way so set a range or limit on how many fields a person can add from the object properties collapsable? or any docs on how to configure it? I looked at the docs I could find, but. options = {'additionalProperties': True } form =…
0
votes
0 answers

Display (4.0) Django models.JSONFields as form in webpage

I am working on a Django based website. I have defined a JSONFields in my backend DB table , let's called it "CampaignTable" The JSONFields is used to store Campaign parameters which might differ from campaign to campaign. I want to collect campaign…
Jia
  • 2,417
  • 1
  • 15
  • 25
0
votes
1 answer

Need to get a custom JSON response for the authentication login and registration page in django

viewset class CustomRenderer(JSONRenderer): def render(self, data, accepted_media_type=None, renderer_context=None): status_code = renderer_context['response'].status_code response = { "status": "success", …
0
votes
1 answer

Putting an ImageField inside a JSONField in Django

I have a jsonfield inside of a django model which is supposed to hold some other fields alongside an ImageField. How can I store the data of the image inside that JSONField and put the image inside the media directory and have it called when I want…
0
votes
2 answers

JSONField filter doesn't show up anything

I am trying to filter a JSONField database according to the country code of the database objects. I have the following JSON dictionary in my JSON field database: "[{\"date\":\"2020-01-01\",\"localName\":\"Neujahr\",\"name\":\"New Year's…
0
votes
0 answers

Django/Django Channels - weird looking json response with double \ between each field

Hello I'm trying to do a real time friend request notification system and having this weird looking json response. I'm new to backend development and django (1st year software engineering student). Im just wondering if this is normal since i havent…
andy
  • 37
  • 5
0
votes
1 answer

Using Django Json field to reduce migrations issue

I am new to Django Json Field. I have been creating models and migrating them for now. Now I am introduced to Jsonfield. What I have heard is, it is the best way to mitigate the migrations issue because of jsonfield. It is because, if we had to add…
0
votes
1 answer

how to post data in django rest in a model that has Jsonfield

I have a task to create a simple post API to send a visitor messages through a contact form that contain fields like full_name,address,phone etc. But instead of creating a model, I have to use an already existing model which has a Jsonfield. Now…
Reactoo
  • 916
  • 2
  • 12
  • 40
0
votes
0 answers

Sorting a JSONField by adding an index value?

I am using a JSONField to store a custom form with field labels/values. I am having an issue when rendering the form. Each time the form gets rendered, the order is changed since I am using a dictionary. I was thinking of adding an extra value to my…
master_j02
  • 377
  • 3
  • 13
0
votes
1 answer

django how to convert request json string to object to process it

I receive this json response from web…
user2035041
  • 69
  • 3
  • 13