Search
 
SCRIPT & CODE EXAMPLE
 

CSS

django json field

# New version
class MyModel(models.Model):
  attribute = models.JSONField(...)

  
  
# Old version (<3.1, Postgres only)
from django.contrib.postgres.fields import JSONField

class MyModel(models.Model):
  attribute = JSONField(...)
Comment

Django JSONField

from django.db import models

class Patient(models.Model):
    name = models.CharField(max_length=256)
    data = models.JSONField()


# Create a patient instance
Patient(name='John Doe', data={
    'address': '123 Some House Number', 
    'city': 'Some City',
    'state': 'Utah',
})

# Filter and delete the patient
Patient.objects.filter(patient='John Doe', data__state='Utah')
Comment

jsonfield django

>>> Dog.objects.create(name='Rufus', data={
...     'breed': 'labrador',
...     'owner': {
...         'name': 'Bob',
...         'other_pets': [{
...             'name': 'Fishy',
...         }],
...     },
... })
>>> Dog.objects.create(name='Meg', data={'breed': 'collie', 'owner': None})

>>> Dog.objects.filter(data__breed='collie')
<QuerySet [<Dog: Meg>]>
Comment

PREVIOUS NEXT
Code Example
Css :: change option tag css 
Css :: css color codes 
Css :: flexbox css properties 
Css :: veritical align inline-block checkbox element 
Css :: tel css 
Css :: dot in image css 
Css :: media query min and max width 
Css :: css animation sin 
Css :: To make multiple equal width buttons occupy container width 
Css :: comment in css 
Css :: css good line height 
Css :: change disbled button background pyqt5 
Css :: css padding 4 values 
Css :: css stopper une animation 
Css :: css text effects 
Css :: radius to imported icons 
Css :: screen sizes for css media 
Css :: var in css 
Css :: animation properties css 
Css :: ui gradient 
Css :: scss extend from another css file 
Css :: remove unused css styles 
Css :: how to set scss variables 
Css :: html css practice projects 
Css :: css selector first level child 
Css :: box shadow css transition 
Css :: list view render queryset 
Css :: css absolute z index less than 
Css :: html externe css einbinden 
Css :: powershell convertto-html css 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =