我已經使用UserProfile方法擴展了用戶模型。不過,我在運行查詢request.user.get_profile() 我認爲,當我已成爲退出的制度,使我的用戶成爲AnonymousUser發生這種情況時,偶爾會Django的錯誤信息UserProfile matching query does not exist。如果UserProfile不存在,是否有任何方法可以自動將用戶重定向回登錄頁面
當嘗試將數據添加到創建的UserProfile模型以保存用戶信息超出在django構建的Auth組件中的用戶信息時,我已經觸及了一堵牆。 我的問題是如何獲得剛剛註冊的用戶實例以創建UserProfile?我認爲這將是類似如下: # Registration form validation etc. is complete
cd = form.cleaned_data
user = User.o
我正在嘗試爲我的django應用創建註冊表單。爲此,我擴展了用戶模型。這是我的 Forms.py from contact.models import register
from django import forms
from django.contrib import auth
class registerForm(forms.ModelForm):
class Meta: