2017-12-28 27 views
1

私はしばらくdjangoでウォーキングしています。今私はdjangoの組み込み関数のいくつかの問題に直面している。 TypeError: 'bool'オブジェクトが呼び出し可能でないというエラー状態。この種のエラーは、 'print(request.user.is_authenticated())'というステートメントのために発生しました。 LoginFormのためにDjangoで認証された組み込み関数でエラーが発生しました

def login_page(request): 
form = LoginForm(request.POST or None) 
#ensure user is logged in or not 
print(request.user.is_authenticated()) 
if form.is_valid(): 
    print(form.cleaned_data) 

return render(request,"auth/login.html",{}) 

()

from django import forms 

class ContactForm(forms.Form): 
    #first will be name which is variable 
    fullname = forms.CharField(widget=forms.TextInput 
     (attrs={"class":"form-control","placeholder":"Your fullname"})) 
    email = forms.EmailField(widget=forms.EmailInput 
     (attrs={"class":"form-control","placeholder":"Your Email"})) 
    content = forms.CharField(widget=forms.Textarea 
     (attrs={"class":"form-control","placeholder":"Your content"})) 

    def clean_email(self): 
     email = self.cleaned_data.get("email") 
     if not "gmail.com" in email: 
      raise forms.ValidationError("Email has to be gmail.com") 
     #return value of email to be stored 
     return email 
class LoginForm(forms.Form): 
    username = forms.CharField() 
    password = forms.CharField() 

答えて

0

forms.py私のファイルによってインポートさそう何がやりたいことはある: は、ここで以下のソースコードである

print(request.user.is_authenticated) 

なし( )は組み込み関数なので

+0

さて、それは今働いています。私の混乱のため、 'is_authenticate()'は組み込み関数 –

関連する問題