admin管理员组文章数量:1352277
<input type="hidden" name="allowed-extensions" value="jpg,jpeg,png" />
I need to convert HTML post input field values or CSV values in a form to a Python list when the form is posted to Django, like in the above scenarios. Kindly let me know. Thank you
<input type="hidden" name="allowed-extensions" value="jpg,jpeg,png" />
I need to convert HTML post input field values or CSV values in a form to a Python list when the form is posted to Django, like in the above scenarios. Kindly let me know. Thank you
Share Improve this question edited Apr 3 at 1:05 tomcaptain asked Apr 1 at 2:10 tomcaptaintomcaptain 336 bronze badges 8- 1 Is there a reason you can't simply edit the form html by hand to make the desired change? – John Gordon Commented Apr 1 at 2:59
- i mean when the form is posted to Django with the post request object! – tomcaptain Commented Apr 1 at 4:55
- 1 What have you tried? This is a pretty basic Django situation. – Tim Roberts Commented Apr 1 at 4:58
- i have tried to convert request.POST with the getlist function but couldn’t convert to Python list! Another practical scenario can be a series or array of input HTML checkboxes – tomcaptain Commented Apr 1 at 5:29
- 1 We need more code to help you. Please post a minimal reproducible example that illustrates what you are trying to do. It should be complete enough that we can copy/paste it and run it ourselves. You can assume that we can create a new django project ourselves. Just provide any custom code that is needed to cause the behavior you are asking about. Note that it should be minimal. That means it doesn't need to be your entire project. Just post enough to show what you have done so far. That will probably include one or more views and a template. – Code-Apprentice Commented Apr 1 at 6:18
1 Answer
Reset to default 1to handle both cases you can do-
allowed_extensions = request.POST.get("allowed-extensions", "").split(",")
本文标签: In Django how to convert HTML post input field values or csv values to Python listStack Overflow
版权声明:本文标题:In Django how to convert HTML post input field values or csv values to Python list - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743912213a2560604.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论