Skip to content

Commit 3b0f49d

Browse files
committed
Example
1 parent 3f42336 commit 3b0f49d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

example/blog/admin.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
from django.contrib import admin
2-
from blog.models import Post
2+
from blog.models import Post, Comment
33

44

5-
admin.site.register(Post)
5+
class CommentInline(admin.TabularInline):
6+
model = Comment
7+
extra = 2
8+
9+
fields = ('content',)
10+
11+
12+
@admin.register(Post)
13+
class PostAdmin(admin.ModelAdmin):
14+
inlines = [
15+
CommentInline,
16+
]

example/blog/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ def get_absolute_url(self):
6969

7070
def __str__(self):
7171
return '{}'.format(self.id)
72+
73+
74+
class Comment(models.Model):
75+
content = EditorJsJSONField(null=True, blank=True)
76+
post = models.ForeignKey(
77+
'Post', related_name='comments', on_delete=models.CASCADE)

0 commit comments

Comments
 (0)