- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
所以我环顾四周,似乎没有人遇到过我不得不导致这个看似常见的错误的相同问题。我在我的 html 中呈现一些表单,如下所示:
<form method="post" action="">
{{ tags_formset.management_form }}
<!-- code displaying this formset -->
...
<!-- -->
<form method="post" action="">
{{ add_all_form.management_form }}
{{ add_all_form.addTagsToAll }}
<input type="submit" value="Add To Displayed Applicants" />
</form>
<form method="post" action="">
{{ remove_all_form.management_form }}
{{ remove_all_form.removeTagsFromAll }}
<input type="submit" value="Remove From Displayed Applicants" />
</form>
<input type="submit" value="Save Changes" />
</form>
当我没有两个内部表单时,表单集会正确显示并且提交按钮可以提交表单。当我添加第二种形式时,出现了几个问题:
-提交按钮停止工作(尽管在选择表单集的字段之一时按 enter 仍会提交表单
-add_all_form 的提交有效并且功能正常(不是问题,但关于下一点很有趣...)
- remove_all_form 在出现“ManagementForm 数据丢失或已被篡改”验证错误时不起作用。
这是创建表单的 views.py 代码:
TagsFormSet = formset_factory(TagsForm, formset=TagFormSet, extra=applicantQuery.count())
if request.method == 'POST':
tags_formset = TagsFormSet(request.POST, request.FILES, prefix='tags', applicants=applicantQuery)
add_all_form = TagAddAllForm(request.POST, request.FILES, prefix='addForm', applicants=applicantQuery)
remove_all_form = TagRemoveAllForm(request.POST, request.FILES, prefix='removeForm', applicants=applicantQuery)
redirect = False
if tags_formset.is_valid():
for tagForm in tags_formset.forms:
if 'tags' in tagForm.cleaned_data:
tagForm.saveTags()
if 'removeTags' in tagForm.cleaned_data:
tagForm.deleteTags()
redirect = True
if add_all_form.is_valid():
if 'addTagsToAll' in add_all_form.cleaned_data:
add_all_form.saveTagsToAll()
redirect = True
if remove_all_form.is_valid():
if 'removeTagsFromAll' in remove_all_form.cleaned_data:
remove_all_form.deleteTagsFromAll()
redirect = True
if redirect:
return http.HttpResponseRedirect('')
else:
initForms = []
tags_formset = TagsFormSet(prefix='tags', applicants=applicantQuery)
add_all_form = TagAddAllForm(prefix='addForm', applicants=applicantQuery)
remove_all_form = TagRemoveAllForm(prefix='removeForm', applicants=applicantQuery)
我简直无法弄清楚出了什么问题。我不知道为什么 add_all_form 在 remove_all_form 不起作用时起作用,因为我基本上复制并粘贴了所有涉及的内容(如果需要,我可以从 Forms.py 文件中发布代码,但我认为问题不在那里.. .)
请帮忙!
最佳答案
你应该只使用一个 <form>
标签。您可以在这里拥有任意数量的提交按钮,并可以显示任意数量的表单,但所有内容都应该在一个 <form>
中。标签。
然后所有管理数据将在表单提交中正确发送,您的问题应该得到解决。
<form method="post" action="">
{{ tags_formset.management_form }}
<!-- code displaying this formset -->
...
<!-- -->
{{ add_all_form.management_form }}
{{ add_all_form.addTagsToAll }}
<input type="submit" value="Add To Displayed Applicants" />
>
{{ remove_all_form.management_form }}
{{ remove_all_form.removeTagsFromAll }}
<input type="submit" value="Remove From Displayed Applicants" />
<input type="submit" value="Save Changes" />
您的 View 可以保持原样。
关于python - 嵌套的 Django 表单 : 'ManagementForm data is missing or has been tampered with' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16073693/
当我尝试在另一台计算机上(不是在生成 key 的 PC 上)在 Android Studio 上构建签名的 APK 文件时,会发生错误: Information:Gradle tasks [:app:
我正在尝试将main流合并到development流,并且需要解析一些文件。解决时出现错误: filepath tampered with before resolve - edit or rever
我一直在尝试 Tampermonkey 并制作脚本来更改 Web 元素。我在 Tamper Monkey 中运行了以下用户脚本: // ==UserScript== // @name "j
我正在开发一个 android 项目,用 debug.keystore 签署我的应用程序(在开发时)...现在我需要使用“真正的”生产 keystore (当我将我的 apk 上传到游戏时使用的那个)
所以,问题来了。 我有这样的东西: // Dangerous __hostObject that makes requests bypassing // the same-origin policy
我嵌入了一个 ReactPlayer,如下所示: { this.setState({ ready: true }); }} onPro
我有一个内部门户网站(仅从 Chrome 打开),我在其中使用 Tamper Monkey 暂时隐藏了一些选项。所以这个脚本只能在少数内部系统中设置。有没有办法禁用 Tamper Monkey 中的选
我知道已经有一些关于这个错误的帖子,但我找不到适合我的问题的答案: 我使用以下命令创建了一个 AES key : keytool -genseckey -alias TEST -keyalg AES
我在我的项目中使用从源代码构建的 ASP.NET 程序集。我的项目构建成功。但是当我以 Debug模式启动时,出现异常 无法加载文件或程序集“System.Net.Http.Formatting”或其
我正在尝试为 Google Maps API 签署我的 Android 应用程序的发布版本(调试已正常签署): keytool -list -alias cancertrials -keystore
我正在使用 python (2.6) 和 mechanize (0.1.11) 编写网络测试脚本。我正在使用的页面有一个带有选择字段的 html 表单,如下所示: A B C
我使用 Android Stuio 0.5.9 作为 IDE我的mac版本10.9.3 以前我使用 oracle java se7 来开发我的应用程序,但是当我更新我的 mac 时它会出现一些版本错误
我的情况很微妙,我的数据库中的某些记录莫名其妙地丢失了。每条记录都有一个序号,序号会跳过整个 block 。我的服务器程序还保存了一个日志文件,记录了所有收到并发布到数据库的事务,那些丢失的记录确实出
您好,我正在创建一个带有动态内联的模型管理员。 class InlineProfile(admin.TabularInline): model = Profile # max_num
我正在我的应用程序中实现一个“锁定”系统,以保护我的应用程序不被非法复制和使用。系统会检查基于硬件的代码的签名,并希望它使用只有我公司拥有的私钥进行签名。 (该应用程序已获得用于验证签名的公钥。) 我
我恢复了旧项目,但当我尝试打开 Project\Option 菜单时出现错误: "keytool error: java.io.IOException: Keystore was tampered w
这个问题在这里已经有了答案: Is there an extension like Tamperdata for Chrome? [closed] (6 个答案) 关闭 9 年前。 我找不到任何与此
我一直在研究关于这个问题的每一个问题,但似乎找不到解决方案。 我正在尝试允许用户提交多个对象并使用带有 2 个外键的表单集保存到数据库。 我可以获取表单以将该数据保存到数据库中,但由于 Managem
几个月前,我使用以下命令生成了我的 android 版本 keystore : keytool -genkey -v -keystore my-release-key.keystore -alias
我是否会通过信任 $_SERVER 变量数组的内容来使用 $_SERVER['PHP_SELF'] 获取 php 文件的名称来冒很大的安全风险? 最佳答案 Many but not all of th
我是一名优秀的程序员,十分优秀!