2017-12-28 9 views
1

잠시 동안 django에서 woking되었습니다. 이제 장고에 내장 된 함수로 몇 가지 문제에 직면하고있다. 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()'는 내장 함수 –

관련 문제