我一直在阅读django rest framework doc,但我找不到如何将参数传递给序列化程序的 init 方法。在常规视图中我喜欢这样:
<div class="row-text" style="width: calc(100% - 84px);">
<span class="row-item-name">
<span class="row-item-link">
<a class="grid-row-element-name">Eclipse111</a>
</span>
<span class="row-item-actions hover-child">
<a>Share</a><span> | </span><a watchdox-rename="name" watchdox-save-func="rename(element, name)" class="rename-link"><span translate="">Rename</span></a>
</span>
</span>
<br>
<span class="row-meta-data">
<span class="creation-date-formatted">Today at 10:30 | </span>
<span class="row-email">orgadmin@mailinator.com</span>
</span>
</div>
<div class="grid-row-buttons">
<div class="row-tools">
<div class="btn-group dropdown" uib-dropdown="">
<button type="button" class="btn btn-default uib-dropdown-toggle clear-button dropdown-toggle" uib-dropdown-toggle="" aria-haspopup="true" aria-expanded="false">
<span class="icon-wd-material-menu"></span>
</button>
<ul uib-dropdown-menu="" class="dropdown-menu-highZ contextual-menu dropdown-menu" role="menu">
</ul>
</div>
</div>
</div>
您是否知道我如何使用CreateAPIView / UpdateAPIView?
来做到这一点感谢您的帮助
答案 0 :(得分:0)
DRF有解决方案。
您需要delivery_id来保存您的实例,在这种情况下,您会将其直接传递到the serializer's save并将其放入sudo apt-get install sumo sumo-tools sumo-doc
/ create
update
您需要进行验证,在这种情况下,您可以将其传递给serializer's context,您可以在序列化程序/字段中将其用作validated_data
。您需要覆盖视图的self.context['request']
。