0
我在我的Django應用程序Admin,Staff和Parent中有三種類型的人。我如何爲他們設置登錄,因爲他們在使用django註冊登錄後會有不同的視圖? 到目前爲止我的代碼是這樣的: settings.py中在django中登錄後創建用戶特定的重定向
LOGIN_REDIRECT_URL = '/app/login_redirect'
LOGIN_URL = '/app/accounts/login/'
LOGOUT_URL = '/app/accounts/logout/'
和views.py:
def login_redirect(request):
if request.user.is_authenticated() and not request.user.is_superuser:
return HttpResponseRedirect(reverse("dashboard"))
elif request.user.is_superuser:
return HttpResponseRedirect(reverse("dashboard"))
我想找出哪些用戶登錄?我的意思是它是一個工作人員用戶或父母用戶或管理員? model.py
class Student(BaseModel):
user = models.ForeignKey("auth.User",blank=True,null=True,related_name="user_%(class)s_objects")
student_name = models.CharField(max_length=128)
admission_number = models.CharField(max_length=128,null=True,blank=True)
transportation_needs = models.CharField(max_length=128, choices=TRANSPORTATION_NEEDS,blank=True,null=True)
extended_care_need = models.CharField(max_length=128, choices=EXTENDED_CARE_NEED,blank=True,null=True)
nationality = CountryField (blank_label='------(select Your Country)-------',max_length=128,blank=True,null=True)
date_of_birth = models.DateField()
permanent_address = models.CharField(max_length=128,blank=True,null=True)
address_for_communication = models.CharField(max_length=128,blank=True,null=True)
gender = models.CharField(max_length=128, choices=GENDER_CHOICE)
你到目前爲止嘗試過什麼?顯示一些代碼或至少詳細說明情景位更詳細... – zaidfazil
我更新了問題 –
如何區分父用戶,是否有字段'is_parent'? – zaidfazil