简体   繁体   English

更新Django POST请求

[英]Update Django POST Request

If my POST request doesn't have a Required field , (say password ), I need to set a temporary password to the field. 如果我的POST请求没有Required field (例如password ),则需要为该字段设置一个临时password Since it is set as Required field , we need to update the POST request somehow. 由于已将其设置为Required field ,因此我们需要以某种方式update POST请求。

How can I implement it? 我该如何实施? Also recommend if there's any alternative method 还建议是否有其他替代方法

Thank in advance, 预先感谢,

The best way would be: 最好的方法是:

my_post_data = request.POST.copy()
if 'password' not in my_post_data:
     my_pass_data['password'] = password_generation_method();

and use my_post_data for rest of the code. 并使用my_post_data作为其余的代码。 No need to play with POST data. 无需处理POST数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM