小编nth*_*all的帖子

Django:TypeError:'username'是此函数的无效关键字参数

我有一个名为Employee的模型用于注册.当我运行代码时,我去了

username' is an invalid keyword argument for this function 
Run Code Online (Sandbox Code Playgroud)

错误.

employee=Employee(user=user, username= form.cleaned_data['username'], email= form.cleaned_data['email'], password=form.cleaned_data['password'])
Run Code Online (Sandbox Code Playgroud)

这是我的view.py代码

from django.http import HttpResponseRedirect
from django.contrib.auth.models import User
from django.shortcuts import render_to_response
from django.template import RequestContext
from Employee_Details.forms import RegistationForm
from Employee_Details.models import Employee

def EmployeeRegistation(request):
if request.user.is_authenticated():
    return HttpResponseRedirect('/profile/')

if request.method=='POST':
    form=RegistationForm(request.POST)
    if form.is_valid():
        user=User.objects.create_user(username= form.cleaned_data['username'],email= form.cleaned_data['email'],password=form.cleaned_data['password'])


        user.save()

        employee=Employee(user=user, username= form.cleaned_data['username'],email= form.cleaned_data['email'],password=form.cleaned_data['password'])
        employee.save()
        return HttpResponseRedirect('/profile/')

    else:
        return render_to_response('registation.html',{"form":form}, context_instance=RequestContext(request))


else:
    '''user is not submitting the form show a blank Registation Form''' …
Run Code Online (Sandbox Code Playgroud)

django django-models django-forms typeerror

6
推荐指数
1
解决办法
3万
查看次数

使用 fabric v2 / paramiko 传输大文件有困难

我正在更新一些以前在 Fabric v1 上运行并且运行良好的代码。但是,现在我在尝试将大约 200MB 大小的文件从本地传输到远程时遇到了问题(在结构 2.5.0 中使用connection.put())。它似乎可以传输,但进一步尝试操作该文件显示只有 7 到 10 MB 成功传输,我的任务失败。

我已经尝试了许多步骤来隔离问题。我可以手动将文件从一台主机传输到另一台主机,没有任何问题。我可以创建一个简单的脚本,如下所示,也可以:

    import subprocess

    ret = subprocess.Popen(['scp', '/tmp/filename', 'host:/tmp/']).wait()
    print(ret)
Run Code Online (Sandbox Code Playgroud)

但即使在我的fabfile.py结果中尝试使用完全相同的代码片段,其行为也与使用相同connection.put()——也就是说,没有错误消息,返回代码为 0,但远程主机上的结果文件为 5-10MB 且已损坏。

我正在运行任务:fab -d deploy --target=stage --prompt-for-passphrase并且调试输出(虽然不是所有 100% 对我来说都是可以理解的)似乎也没有立即与问题相关。我在哪里可以调试这个并找到一个有效的解决方案?

编辑:相关版本信息:

  • 本地蟒蛇:3.6.8
  • 远程蟒蛇:3.6.9
  • 面料:2.5.0
  • 参数:2.6.0

python paramiko fabric

6
推荐指数
1
解决办法
144
查看次数