Django:如果我们使用自定义temp,如何在内联模型中找到上下文变量

2024-05-15 03:51:29 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的代码

class CommentInline(admin.StackedInline):
    model= Comments
    extra=0


    template = "admin/comments.html"



class BlogAdmin(admin.ModelAdmin):
    inlines = [CommentInline]

admin.site.register(Blog,BlogAdmin)

在comments.html文件中

{% for comments in comments_list %}
    {{ comments.name }}
{% endfor %}

但它不打印任何内容,但如果使用默认模板,它将打印值

我只是尝试使用不同的模板内联类


Tags: 代码模板modeladminhtmltemplateextracomments

热门问题