感谢Insin回答了与此相关的上一个问题.
他的回答有效并且运作良好,但是,我对'cleaning_data'的提供感到困惑,或者更确切地说,如何使用它?
class RegistrationFormPreview(FormPreview):
preview_template = 'workshops/workshop_register_preview.html'
form_template = 'workshops/workshop_register_form.html'
def done(self, request, cleaned_data):
# Do something with the cleaned_data, then redirect
# to a "success" page.
registration = Registration(cleaned_data)
registration.user = request.user
registration.save()
# an attempt to work with cleaned_data throws the error: TypeError
# int() argument must be a string or a number, not 'dict'
# obviously the fk are python objects(?) and not fk_id
# but how to proceed here in an easy way?
# …Run Code Online (Sandbox Code Playgroud) 我将用户数据存储在名为Users的MSSQL表中.我想要的是访问实际登录用户的所有用户数据(电子邮件,地址,电话,如果用户是订户等).
我不想使用配置文件,所以我决定使用自定义MembershipProvider(或者你知道一些更好,更少痛苦的方式吗?).
我不明白的是MembershipUser和Membership.如果我从MembershipProvider继承,则在重写方法中,我控制从数据库到数据库的访问数据.
但是如何使用MembershipProvider中的继承类?如果我想通过使用成员资格来验证用户,我应该这样做:
if(Membership.ValidateUser(string username, string password))
{
FormsAuthentication.RedirectFromLoginPage(string username, string password);
}
Run Code Online (Sandbox Code Playgroud)
但是从MembershipProvider继承的类在哪里?何时使用从MembershipUser继承的类?会员资格与会员资格提供者之间的关系是什么?
出于某种原因,似乎Adda HashSet上的Contains操作比元素已经存在时的操作要慢HashSet.
这是证明:
Stopwatch watch = new Stopwatch();
int size = 10000;
int iterations = 10000;
var s = new HashSet<int>();
for (int i = 0; i < size; i++) {
s.Add(i);
}
Console.WriteLine(watch.Time(() =>
{
for (int i = 0; i < size; i++) {
s.Add(i);
}
}, iterations));
s = new HashSet<int>();
for (int i = 0; i < size; i++) {
s.Add(i);
}
// outputs: 47,074,764
Console.WriteLine(watch.Time(() =>
{
for …Run Code Online (Sandbox Code Playgroud) 我一直想知道为什么微软为这样一个伟大的平台选择了这样一个奇怪的,搜索引擎不友好的名字.难道他们没有想出更好的东西吗?
显然,代号为NGWS:
微软最初以下一代Windows服务(NGWS)的名义在20世纪90年代末开始在.NET Framework上进行开发.[百科]
有谁知道他们为什么选择.NET这个名字?
如何在Python中对集合运行操作并收集结果?
所以,如果我有一个包含100个数字的列表,我想为每个数字运行这样的函数:
Operation ( originalElement, anotherVar ) # returns new number.
Run Code Online (Sandbox Code Playgroud)
并收集结果如下:
结果=另一个清单......
我该怎么做?也许使用lambdas?
假设你有这样的价值:
n = 5
以及返回它的阶乘的方法,如下所示:
因子(5)
你如何处理多个值:
nums = [1,2,3,4,5]
因子(nums)
所以它将所有这些值的阶乘返回为列表.
如果不编写2种方法,最简洁的方法是什么?python有一个很好的方法来处理这种情况吗?
如何搜索vs 2008 Team Explorer中其他用户签出的文件.我可以通过搜索搜索Visual Source Safe项目中检出的所有文件,是否在团队资源管理器中实现了类似的功能?现在我必须点击每个文件夹,看看该文件夹中的文件是否被其他任何人检出.
谢谢
我想知道是否有人有更优雅的方法来检查.NET中的SQL的唯一键异常,而不是解析错误消息?现在我在SQL中调用sproc,然后在.NET中使用try catch块.在try catch块中我解析错误消息,它是一个唯一键错误我向调用类抛出一个自定义错误的实例,如果不是我只是将原始异常抛出到调用类.这对我来说似乎非常低效.
我有一个Windows窗体应用程序,它为StartInfo提供用户名,域和密码,它会抛出:
System.ComponentModel.Win32Exception:句柄 在System.Diagnostics.Process.Start()的System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)中无效
当我允许凭证默认为当前用户时,我没有得到这样的错误,并且我开始的过程工作到不需要使用凭证的程度(在MSBuild脚本中映射驱动器所需的信用).这是填充开始信息的代码:
Process p = new Process();
ProcessStartInfo si = new ProcessStartInfo(buildApp, buildArgs);
si.WorkingDirectory = msBuildWorkingDir;
si.UserName = txtUserName.Text;
char[] psw = txtPassword.Text.ToCharArray();
SecureString ss = new SecureString();
for (int x = 0; x < psw.Length; x++)
{
ss.AppendChar(psw[x]);
}
si.Password = ss;
si.Domain = "ABC";
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
si.WorkingDirectory = txtWorkingDir.Text;
p.StartInfo = si;
p.Start();
Run Code Online (Sandbox Code Playgroud)
并不是用户/ psw不匹配,因为当我提供一个糟糕的psw时,它会抓住它.因此,这个"无效句柄"的事情在信用证通过后发生.关于我可能会忽略或搞砸的任何想法?
有人知道Python是否具有与Java的SortedSet接口等效的东西吗?
继续我正在寻找的东西:假设我有一个类型的对象foo,我知道如何比较两个类型的对象,foo看看foo1是"大于"还是"小于" foo2.我想要一种foo在列表中存储许多类型对象的方法L,这样每当我遍历列表时L,我按照我定义的比较方法按顺序获取对象.
我想我sort()每次修改它都可以使用字典或列表,但这是最好的方法吗?
python ×4
.net ×3
c# ×2
list ×2
asp.net ×1
django ×1
django-forms ×1
hashset ×1
lambda ×1
membership ×1
performance ×1
sql ×1
terminology ×1