We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f42336 commit 3b0f49dCopy full SHA for 3b0f49d
example/blog/admin.py
@@ -1,5 +1,16 @@
1
from django.contrib import admin
2
-from blog.models import Post
+from blog.models import Post, Comment
3
4
5
-admin.site.register(Post)
+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
@@ -69,3 +69,9 @@ def get_absolute_url(self):
69
70
def __str__(self):
71
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