1

在我的應用程序中,我有3種具有不同權限的用戶。人力資源,員工和候選人。Django創建一個僅使用電子郵件的用戶並將其設置爲不活動

我希望能夠創建一個僅提供其電子郵件的用戶員工並將其設置爲非活動狀態當員工登錄到應用程序時,他設置了他的名字,姓氏和密碼,併成爲活動應用程序

我開始在Django,真的不知道該怎麼做;

我使用的文件開始的認證過程,我得到:

views.py:

from django.shortcuts import render 
from .forms import HRForm, CandidateForm, EmployeeForm 
from django.core.urlresolvers import reverse 
from django.contrib.auth.decorators import login_required 
from django.http import HttpResponse, HttpResponseRedirect 
from django.contrib.auth import authenticate,login,logout 
from django.contrib.auth.backends import ModelBackend 
from .models import MyUser 

def registerEmployee(request): 
    registered = False 
    if request.method == "POST": 
     Employee_form = EmployeeForm(data=request.POST) 

     if Employee_form.is_valid(): 
      user = Employee_form.save() 
      user.set_password(user.password) 
      user.is_employee = True 
      user.save() 
      registered = True 
     else: 
      print("Error!") 
    else: 
     Employee_form = EmployeeForm() 
    return render(request,'Employee_registration_form.html', 
          {'Employee_form':Employee_form, 
          'registered':registered}) 

能否請你幫我或者給我方向潛水? THX你;)

+0

可以看看這個HTTPS: //docs.djangoproject.com/en/1.11/topics/auth/customizing/ – Robert

回答

相關問題