设置extra 就可以改变inline数量
class InlineModelAdmin(BaseModelAdmin):
"""
Options for inline editing of ``model`` instances.
Provide ``fk_name`` to specify the attribute name of the ``ForeignKey``
from ``model`` to its parent. This is required if ``model`` has more than
one ``ForeignKey`` to its parent.
"""
model = None
fk_name = None
formset = BaseInlineFormSet
extra = 1
min_num = None
max_num = None
template = None
verbose_name = None
verbose_name_plural = None
can_delete = True
show_change_link = False
checks_class = InlineModelAdminChecks
classes = None
更新指定或部分数据
class AccountUserSerializer(serializers.ModelSerializer):
class Meta:
model = AccountUser
fields = ('name','mobile','province',)
class AccountUserSerializer(serializers.ModelSerializer):
class Meta:
model = AccountUser
fields = ('name','mobile','province','city','country','detail','zone','the_index')
AccountUserSerializer只能更新'name','mobile','province',即使传递了其他数据也不能更新,所以在显示的时候只会显示'name','mobile','province'。在更新和创建的时候也只会更新创建'name','mobile','province'。如果想要显示的字段和先要创建更新的字段不一样就要注意了。