当我向django admin
添加多个内联时,Add another {model name}
将消失。如果我检查javascript控制台,我会看到以下错误:
Uncaught TypeError: Cannot read property 'fn' of undefined
at inlines.js:20
at inlines.js:295
这是我的Django管理员:
@admin.register(models.Paper)
class PaperAdmin(BaseLiteratureAdmin):
class EditedPaperAdminInline(admin.StackedInline):
model = models.EditedPaper
extra = 0
class SupplementaryInformationAdminInline(admin.StackedInline):
model = models.SupplementaryInformation
extra = 0
class PaperNotesAdminInline(BaseNotesAdminInline):
exclude = tuple(
i for i in BaseNotesAdminInline.exclude if i != 'paper'
)
class ReferencedPaperInline(admin.StackedInline):
model = models.Paper.referenced_papers.through
extra = 0
fk_name = 'from_paper'
verbose_name = "Referenced Paper"
verbose_name_plural = "Referenced Papers"
inlines = (
EditedPaperAdminInline, # problem
PaperNotesAdminInline, # ok single/together
ReferencedPaperInline, # ok single/together
SupplementaryInformationAdminInline, # problem
)
我找到了一个解决方案——改变inlines
列表中内联线的顺序,如下所示:
每个内联旁边的注释注意到PaperNotesAdminInline
和{inlines
列表,则所有内容都会正确加载。在
这是怎么回事?在
我在我的项目中也遇到了同样的问题,在一个大型的富表单脚本上内联.js在jQuery之前加载并生成错误。 我加了个零钱内联.js在我的项目文件夹中,它会检查jQuery是否已加载,如果没有,它将等待300毫秒,然后重试。 贴在这里。在
相关问题 更多 >
编程相关推荐