我已使用此处的链接公开了管理网站中的多个数据库:django-docs。现在,我需要覆盖默认管理网站中公开的模型之一的change_list.html,并在页面上添加一个按钮。这是文件项目/ templates / admin / my-app / my-model / change_list.html
中的代码def main():
outfile = open('golf.txt', 'w')
# Change this:
count = 0
print("You will be asked to enter players names and scores")
print("When you have no more names, enter End")
print("\n")
while True:
name = input("Enter Player's Name or end to end program:")
if name == "end":
break
score = input("Enter {}'s golf score: ".format(name))
outfile.write(name + "\n")
outfile.write(str(score) + "\n")
# add this:
count += 1
# change this:
print("You have written {} players records to golf.txt".format(count))
outfile.close()
main()
不知何故,这个javascript不起作用。我之前已经覆盖了django admin html,但是在这个项目中,我暴露了多个数据库(多个管理站点的类型),那么在这里是否需要做一些不同的事情来覆盖admin html?
答案 0 :(得分:0)
您需要在admin.py
中指向该模板class YourAdmin(admin.ModelAdmin):
change_list_template = 'admin/my-app/my-model/change_list.html'
我会使用django.jQuery(document).ready()
代替$(document).ready()