我有两个表 Defendant 和 Defendant_Potential
class Defendant(models.Model):
fullname = models.CharField(max_length = 100, null = False,)
fname = models.CharField(max_length = 100, verbose_name = u'First Name', blank = True, null = True,)
midname = models.CharField(max_length = 100, verbose_name = u'Middle Name', blank = True, null = True,)
lname = models.CharField(max_length = 50, verbose_name = u'Last Name', null = True, blank = True,)
marked = models.CharField(max_length = 50, verbose_name = u'Check box mark', null = True, blank = True,)
class Defendant_Potential(models.Model):
defendant = models.ForeignKey('Defendant', related_name = "Defendant_defendantID",)
midname = models.CharField(max_length = 100, blank = True, null = True, default = None)
address = models.CharField(max_length = 100, null = False,)
city = models.CharField(max_length = 50, null = False,)
state = models.CharField(max_length = 5, null = False,)
zip = models.CharField(max_length = 50, null = False,)
及其管理模型如:
class Defendant_Potential_Individual_Inline(admin.TabularInline):
model = Defendant_Potential
formset = NoDeleteAdminInlineFormSet
readonly_fields = ('midname', 'address')
extra = 0
template = "admin/cdradmin/defendant/edit_inline/tabular.html"
class DefendantAdmin(admin.ModelAdmin):
list_display = ('fullname', 'fname','midname','lname')
inlines = [Defendant_Potential_Individual_Inline, ]
在 tabular.html 我有一个自定义复选框
<td><input type="checkbox" name="defendant_potential_checked" data-defendant_id="{{ inline_admin_form.original.defendant_id }}" value="{{ inline_admin_form.original.id }}"></input></td>
我的Qustion是每当检查复选框时,“被告”表获得更新标记的字段(这应该发生OLNY,我们单击canse_from.html上的提交按钮。
我对 save_model、save_formset 等进行了一些研究但我没有得到任何人可以帮助我做到这一点的正确解决方案?