我想将参数{{x}}
传递给我自定义的文件/home/django/project/app/template/admin/change_form.html
,但是我发现下面这段代码不起作用:
class MyModelAdmin(admin.ModelAdmin):
# A template for a very customized change view:
change_form_template = 'admin/change_form.html'
def get_osm_info(self):
z = Klass()
x = z.final_down()
return x
def change_view(self, request, object_id, extra_context=None):
my_context = { 'x': get_osm_info(),}
return super(MyModelAdmin, self).change_view(request, object_id,extra_context=my_context)
Klass
和final_down
是什么会有所帮助。 - Daniel Roseman