[英]Is it possible to get the value of an item contained in Django's “changed_data” list?
I have the following code in my Django application: 我的Django应用程序中包含以下代码:
if 'book' in authorForm.changed_data:
#Do something here...
I realize Django can tell me which values have changed in my form by utilizing the "changed_data" list object, but I'd like to know the new values of the fields that have changed. 我意识到Django可以利用“ changed_data”列表对象告诉我表单中哪些值已更改,但是我想知道已更改字段的新值。
Any thoughts? 有什么想法吗?
Hmm... Try this: 嗯...试试这个:
if authorForm.is_valid() and 'book' in authorForm.changed_data:
new_value = authorForm.cleaned_data['book']
我最初的问题的简短答案是“否”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.