인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

cyh60993013's profile image
cyh60993013

asked

Django with determination! Make Pinterest with Django: From the ground up to deployment

회원가입 화면 help_text제거

Written on

·

163

0

안녕하세요! createView생성 강의를 들으면서 따라서 코딩을 하다보니 username부분에 나오는 'Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.' 이런 문구를 제거하고 싶어 강의 질문들을 찾아보고, 구글링을 해봐도 username만 지워지고 password1,2는 지워지지 않더라구요. 혹시 해결방안을 아시나요??

class AccountCreationForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2', ]
help_texts = {
'username': None,
'password1': None,
"password2" : None
}
pythondockerdjango

Answer 1

1

noeul1114님의 프로필 이미지
noeul1114
Instructor

안녕하세요!
질문 확인했습니다.

해당 부분을 없애주기 위해선 Meta 태그 내의 정보를 변경하는 것이 아닌,
실제 Help text 데이터를 삭제해주어야 합니다.

그래서 초기화 메서드, __init__ 메서드를 오버라이딩 하여 해당 부분을 구현하게 되면,


class
AccountCreationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].help_text = ""
self.fields['password1'].help_text =
""

이런식으로 특정 fields 의 help_text 를 공백으로 변경함으로서 
원하시는 결과를 얻으실 수 있습니다.

혹은 내용을 원하시는대로 바꿀 수도 있구요.

답변이 도움이 되셨으면 좋겠네요.
좋은하루 보내시길 바래요!
감사합니다-

cyh60993013's profile image
cyh60993013

asked

Ask a question