Answer the question
In order to leave comments, you need to log in
How to add an action when creating a new element via admin.StackedInline(Django)?
сlass ThreadInLine(admin.StackedInline):
model = Comment
extra = 1
fields = ['comments_tittle', 'comments_text', 'comments_image']
class ThreadAdmin(MyModelAdmin):
inlines = [ThreadInLine]
fields = ['board', 'thread_tittle', 'thread_text', 'thread_image']
search_fields = ['thread_tittle', 'id']
list_filter = ('board__board_shortcut',)
def save_model(self, request, obj, form, change):
if change is False:
board = Board.objects.get(board_shortcut=obj.board)
board.board_posts += 1
board.save()
obj.save()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question