I had two choices

As cool as this new admin comment thing is, either I have to include all required fields in the inline otherwise it will throw an error when adding a new comment, or simply make it mostly read only and keep it simple.
This commit is contained in:
some weird guy
2023-09-08 13:04:31 -07:00
parent 4197b44b63
commit bcec15ab07
+7 -2
View File
@@ -88,8 +88,13 @@ class ConversationAdmin(admin.ModelAdmin):
class CommentsInline(admin.TabularInline): class CommentsInline(admin.TabularInline):
model = models.Comment model = models.Comment
extra = 0 extra = 0
fields = ('creator', 'body', 'is_rm') fields = ('creator', 'body', 'is_rm', )
raw_id_fields = ('creator',) readonly_fields = ('creator', )
def has_add_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False
class PostAdmin(admin.ModelAdmin): class PostAdmin(admin.ModelAdmin):
inlines = [CommentsInline] inlines = [CommentsInline]