0
오류 수정을 도와주십시오데이터베이스에서 사용자 이름을 검색하는 방법은 무엇입니까?
사이트에 추가하고 사용자 프로필에 인증 시스템에 액세스하십시오. 각 사용자는 로그인을 변경할 수 있습니다.
from django import forms
from userprofile.models import UserProfile
from django.contrib.auth.models import User
from django.conf import settings
import os
class UserProfileForm (forms.ModelForm):
class Meta:
model = UserProfile
fields = ('family', 'name', 'nation', 'status', 'login', 'nation_show')
def clean_family (self):
family = self.cleaned_data ['family']
letters_quantity = len (family)
if letters_quantity < 4 :
raise forms.ValidationError (" little beech in the name! ")
return family
def clean_login (self):
login = self.cleaned_data ['login']. strip()
if login! ='':
login_form_db = User.objects.filter (username = 'qwe')
if login_form_db:
login_form_db = login_form_db.username
if login == login_form_db:
raise forms.ValidationError (" this username is busy ")
else:
User.username = login
User.save (self)
return login
을하지만 결국 나는 다음과 같은 메시지가 오류 얻을 :이 그가 로그인 정보를 입력하고 클릭 할 수있는 다음과 같은 형태로 제출해야
AttributeError at/userprofile/
'QuerySet' object has no attribute 'username'
Request Method: POST
Request URL: http://127.0.0.1:8000/userprofile/
Django Version: 1.6.2
Exception Type: AttributeError
Exception Value:
'QuerySet' object has no attribute 'username'
Exception Location: c: \ Python33 \ django_projects \ mutants \ userprofile \ forms.py in clean_login, line 26