保存自定义表单django的formset(Save a formset of custom forms django)
我想在django中保存一个formset。 为此,我有我的模型和自定义表单。 然后我以这种方式创建我的formset:
QuoteFormSet = formset_factory(QuoteForm, extra=2) formset = QuoteFormset(request.POST)
但是当我执行formset.save()时我得到了
AttributeError: 'QuoteFormFormSet' object has no attribute 'save'
我的模特:
class Quote(models.Model): country = models.CharField(max_length=2,) street = models.CharField(max_length=100,)
我的表格:
class QuoteForm(forms.ModelForm): class Meta: model = Quote country = forms.ChoiceField(choices=COUNTRIES, required=False) street = forms.CharField(max_length=100, required=False)
I am trying to save a formset in django. To do so I have my model and a customized form. Then I create my formset this way :
QuoteFormSet = formset_factory(QuoteForm, extra=2) formset = QuoteFormset(request.POST)
But when I do formset.save() i get
AttributeError: 'QuoteFormFormSet' object has no attribute 'save'
my model :
class Quote(models.Model): country = models.CharField(max_length=2,) street = models.CharField(max_length=100,)
My form:
class QuoteForm(forms.ModelForm): class Meta: model = Quote country = forms.ChoiceField(choices=COUNTRIES, required=False) street = forms.CharField(max_length=100, required=False)
原文:https://stackoverflow.com/questions/16040493
最满意答案
有了更多的BotBuilder经验,我相信这完全取决于主机应用程序。 我现在正在研究CRUD的数据库并查询用户。
With a little more BotBuilder experience, I believe that this is entirely up to the host app. I am now working on a database to CRUD and query the users.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
在Heroku上预编译资源时如何通用跳过数据库触摸(How to universally skip database touches when precompiling assets on Heroku)[2023-11-25]
编辑:这个答案是过时的,不再有效 - 见fringd的答案。 不是一个通用的存根,但设计现在增加了一个检查来解决这个特定的问题。 查看问题并修复 Github。 通过提供RAILS_ASSETS_PRECOMPILE环境配置设计应该跳过建立路由 EDIT: This answer is out of date and no longer works - See fringd's answer. Not quite a universal stubbing but devise has added a che ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
服务器上的React需要将应用程序呈现为对浏览器有意义的HTML字符串。 同时,浏览器中的React需要阅读此HTML并理解它与JS代码的关系:它需要以非常详细的方式识别哪个DOM树来自哪个React组件。 因此,实际上,中间HTML是服务器上的React和客户端上的React之间的序列化格式,即使在没有React的情况下,它对浏览器也有意义。 当您启用高级Cloudflare功能时,它会将HTML视为“常规”HTML,而不是花哨的服务器端呈现组件。 我对一件可能出错的事情毫无根据的猜测是剥离HTML评论。 ...
-
它可能是ES5因为该标准是在2009年设置的。您可以使用babel,nodejs库,gulp或webpack或任何构建系统(甚至可以)将ECMA-2015/ES6代码转换为ES5 。 有关ES2015功能的信息 。 设置babel - 选择一个构建系统 。 It is probably ES5 as the standard was set in 2009. You can use babel, a nodejs library, with gulp or webpack or whatever build ...
-
基于加工到用户定义的字符串的行变化,通用(Mutate rows based on maching to user defined strings that works universally)[2022-10-18]
library(dplyr) library(stringr) clas <- c("CD_1","X.2_2","K$2_3","12k3_4",".A_5","xy_6") df <- data.frame(clas) df %>% mutate(clas = str_replace(clas, "(.)(_[456])", "B\\2")) 这里把匹配的模式创建一个3组匹配,第一个包含整个表达式匹配._[456] ,第二个包含. 部分和第三部分包含_[456]部分。 \\2访问第三组(0索引), ... -
你确定:悬停是发生了什么? css规则通常都会开启 :hover, :focus 或类似的东西。 :悬停不应该在触摸设备上发生,但是:一旦触摸链接就会发生焦点。 你可以打破你的悬停并将规则彼此分开。 或者,您可以使用modernizr来检测它在body元素上创建的类的触摸支持和样式。 Are you sure that :hover is what's happening? Often the css rule will be on :hover, :focus or something like th ...
-
支持附件的最普遍可导入的电子邮件文件格式?(Most universally importable e-mail file format with attachment support?)[2023-02-19]
Outlook应该能够很好地处理EML文件。 Outlook无法处理的MIME部分的实际MIME标头是什么? 您也可以使用MSG文件格式,但它是二进制的,只有Outlook可以理解它。 Outlook should be able to handle EML files just fine. What is the actual MIME header of the MIME part that Outlook cannot handle? You can also use MSG file format, ... -
普遍找到一个用户(Find a user universally)[2024-02-17]
有了更多的BotBuilder经验,我相信这完全取决于主机应用程序。 我现在正在研究CRUD的数据库并查询用户。 With a little more BotBuilder experience, I believe that this is entirely up to the host app. I am now working on a database to CRUD and query the users. -
找到联系人最多的用户(Find the user with the most contact)[2021-12-02]
SQL Server 2005 +,使用CTE: WITH usr_list AS ( SELECT x.user_id, x.message_from_user AS other_user FROM TABLE x UNION SELECT y.user_id, y.message_to_user AS other_user FROM TABLE y) SELECT TOP 1 ul.user_id, ...