File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
styleguide_example/blog_examples/f_expressions Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 2
2
from django .db .models .expressions import Func
3
3
from django .db .models .functions import Cast
4
4
5
- """
6
- An F() object represents the value of a model field, transformed value of a model field, or annotated column.
7
- It makes it possible to refer to model field values and perform database operations using them without actually
8
- having to pull them out of the database into Python memory.
9
- """
10
-
11
5
12
6
class JSONIncrement (Func ):
7
+ """
8
+ This is an example from this blog post
9
+ - https://www.hacksoft.io/blog/django-jsonfield-incrementation-with-f-expressions
10
+ Django docs reference
11
+ - https://docs.djangoproject.com/en/4.2/ref/models/expressions/#f-expressions
12
+ """
13
+
13
14
function = "jsonb_set"
14
15
15
16
def __init__ (self , full_path , value = 1 , ** extra ):
Original file line number Diff line number Diff line change 1
1
from django .db import models
2
2
3
- """
4
- This is a basic model used to illustrate
5
- JSON field increment with f expressions
6
- """
7
-
8
3
9
4
class SomeDataModel (models .Model ):
5
+ """
6
+ This is an example from this blog post
7
+ - https://www.hacksoft.io/blog/django-jsonfield-incrementation-with-f-expressions
8
+ """
9
+
10
10
name = models .CharField (
11
11
max_length = 255 ,
12
12
blank = True ,
You can’t perform that action at this time.
0 commit comments