小编Lah*_*uzz的帖子

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万
查看次数

Django:登录员工用户时,从Django管理面板中删除超级用户复选框

我需要编辑django管理面板.在我的应用程序中,超级用户可以添加用户并可以分配权限.当超级用户添加HR管理员等用户时,应用程序应该允许添加用户.有用.但我需要做的是当员工用户登录管理面板时隐藏超级用户状态栏.我怎样才能做到这一点?我应该改变什么Django管理文件?如何?

django django-admin

2
推荐指数
3
解决办法
4463
查看次数

使用jquery自动聚焦div标签不起作用

我需要为div标签添加自动对焦功能.为此,我试过了

<script type="text/javascript" >
            $(document).ready(function() {
                $("div_error").focus();
            });

    </script >
Run Code Online (Sandbox Code Playgroud)

但这并不关注我的div标签.它正常加载页面.

 <div  id="div_error">some text</div>
Run Code Online (Sandbox Code Playgroud)

我错过了什么

html javascript jquery

0
推荐指数
1
解决办法
5415
查看次数