Django-Admin: integrating custom forms

好久不见. 提交于 2019-12-03 08:56:49

You definitely need to use your own template, or modify the change form but also modify the change view. For example, it should be trivial to add this import into the change form itself.

Django's admin uses a lot of magical things for its admin, and those templates have many tags that are specific to the objects passed in via its change/changelist views.

Extend admin/base_site.html instead and you're good to go.

you need to pass to the view's context two more variables:

context['opts'] = RfigTag._meta
context['app_label'] = RfigTag._meta.app_label

Maybe you just need do:

class RfidTagAdmin(admin.ModelAdmin):
      form = RfidImport
      ...

Refer to: https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!