改变inline显示的数量
设置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'。如果想要显示的字段和先要创建更新的字段不一样就要注意了。
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦