改变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'。如果想要显示的字段和先要创建更新的字段不一样就要注意了。
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫(xiě)下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦