- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Request Method: GET
Request URL: http://localhost:8080/user/create
Django Version: 1.5.1
Exception Type: TypeError
Exception Value: ____init____() got an unexpected keyword argument 'instance'
Exception Location: /place/venv/local/lib/python2.7/site-packages/django/views/generic/edit.py in get_form, line 35
Python Executable: /place/venv/bin/python
Python Version: 2.7.3
class UserCreateView(CreateView):
model = models.User
form_class = forms.UserForm
url(r'^user/create$', UserCreateView.as_view(), name='user_create'),
class UserForm(forms.Form):
GROUP_CHOICES = [(-1, '[Choose]')]
GROUP_CHOICES += [(group.id, group.name.capitalize()) for group in auth.models.Group.objects.all()]
email = forms.EmailField(
label='Email',
widget=forms.TextInput(attrs={'placeholder': 'Email'})
)
first_name = forms.CharField(
label='First Name',
widget=forms.TextInput(attrs={'placeholder': 'First Name'})
)
last_name = forms.CharField(
label='Last Name',
widget=forms.TextInput(attrs={'placeholder': 'Last Name'})
)
password = forms.CharField(
label='Password',
widget=forms.PasswordInput(attrs={'placeholder': 'Password'})
)
password_validation = forms.CharField(
label='Repeat Password',
widget=forms.PasswordInput(attrs={'placeholder': 'Repeat Password'})
)
mobile_number = forms.CharField(
label='Mobile Number',
widget=forms.TextInput(attrs={'placeholder': 'Mobile Number'})
)
office_number = forms.CharField(
label='Office Number',
widget=forms.TextInput(attrs={'placeholder': 'Office Number'})
)
group = forms.ChoiceField(
label='Group',
choices=GROUP_CHOICES
)
def clean_password_validation(self):
if self.cleaned_data['password'] == self.cleaned_data['password_validation']:
return self.cleaned_data['password_validation']
else:
raise forms.ValidationError('Passwords don\'t match')
def clean_group(self):
if self.cleaned_data['group'] != -1:
return self.cleaned_data['group']
else:
raise forms.ValidationError('Please, choose a group')
class User(models.Model):
user = models.OneToOneField(auth.models.User)
mobile_number = models.CharField(max_length=64)
office_number = models.CharField(max_length=64)
最佳答案
我怀疑 UserForm
类应该是模型形式。您可能想要更改字段,但它应该从 `ModelForm.
因此将表单定义更改为
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = [...] # list of fields you want from model
#or define fields that you want.
....
关于django - Getting __init__() got an unexpected keyword argument 'instance' with CreateView of Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16079299/
import csv import numpy as np from sklearn.svm import SVR import matplotlib.pyplot as plt dates = []
我在 ANTLRWorks 1.4 中有以下语法。我正在考虑在文本冒险游戏创建器中实现解析器的想法,其中用户将为他的游戏指定各种允许的命令。 grammar test; parse :
我有一个 .dat 文件,我首先想将其转换为 .csv 文件,然后根据时间绘制一些行,我的脚本如下: import pandas as pd import numpy as np from sys i
python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法 前言:
我有一个我无法理解的问题,因此在删除按钮中,尝试在创建按钮后将其删除的地方,出现以下错误: Delete=Button(root,text='Delete',command=lambda : S.pa
我想将某个函数作为线程运行,但我得到了 SyntaxError: non-keyword arg after keyword arg 我不明白为什么: #!/usr/bin/env python im
我试图在 scrappy 中抓取多个页面,我的函数确实返回第一个起始网址,但我无法设法使蜘蛛的规则生效。 这是我到目前为止所拥有的: import scrapy from scrapy.contrib
我正在使用 emeditor,我试图从法语维基百科转储 .xml 文件(20GB,3.38 亿行,总共 480 万篇文章)中分离出大约 200 万篇包含 keyword3 的文章。我想将文本包含在 2
发布表如下所示: publications ============ id title etc ... 关键字表如下所示: keywords ======== id name etc ... keyw
我有这个功能: def crypting(self, client, access_token, client_id, client_secret, oauth_scope, redirect_uri
我正在学习 Rails,但在以下代码中出现语法错误 unexpected keyword else, expected keyword end,我不知道为什么。
我正在一个网站上工作,我必须在数据库中搜索根域上/之后的字符串。我在文档中找不到任何有关它的信息。我正在尝试使其与 Iron Router 一起使用,但任何其他建议都会起作用。 感谢您的帮助! 编辑:
我刚刚找到有关 apache solr 的信息,并且在我成功安装了带有 Tomcat 的 apache Solr 之后。然后我开始使用 Apache Solr 进行搜索。 但我对 Apache Sol
我是 Angular JS 新手。我无法弄清楚过滤器如何仅对对象中的名称起作用,而不是对对象中的电话键起作用。就好像我们在 ng-model 中仅使用关键字一样,它将过滤范围中定义的对象中的名称和电话
当我运行以下代码行时,我试图将按钮按下绑定(bind)到 Tkinter 中的函数 get = Button(root, lambda: ChangeColour(boxes[1][2], boxes
response = requests.post("http://api.bf3stats.com/pc/player/", data = player, opt) 在 python IDLE 中运行
这是我正在操作的更新查询。此处错误“set data = :updateValue”,数据是 Dynamo DB 的保留关键字。我想我应该在这里使用 update ExpressionAttribut
根据维基百科,二元运算符 ?:是 colloquially referred to as the Elvis operator due to its resemblance to an emotico
我知道 AND 词定义了二进制 and ...但什么定义了逻辑and ? 最佳答案 同一个字,AND , 也用于逻辑与。但是这两个输入值要AND推荐为格式良好的标志 ; 真和 假 由两个值表示,位全部
反引号运算符的固定性是什么? 例如在 Real World Haskell 的这段代码中: ghci> (1+) `fmap` [1,2,3] ++ [4,5,6] [2,3,4,4,5,6] 很明显
我是一名优秀的程序员,十分优秀!