2017-11-18 5 views
0

django 폼에서 필드 레이블을 변경하려고하지만 placeholder를 추가하고 싶지만 placeholder 속성을 설정하면 필드 레이블이 작동하지 않고 "Bio"대신 "work_or_study"라는 기본 필드 레이블이 표시됩니다. .django에서 자리 표시자를 추가하고 양식 필드 레이블을 동시에 변경하는 방법은 무엇입니까?

class ProfileEditForm(forms.ModelForm): 
date_of_birth=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'y-m-d'})) 
work_or_study=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'something interesting about you'})) 
class Meta: 
    model= Profile 
    labels = {"work_or_study":"Bio"} 
    fields = ('date_of_birth','work_or_study') 

답변

0

레이블이

work_or_study=forms.CharField(widget=forms.TextInput(attrs={'placeholder':'something interesting about you'})) 

work_or_study=forms.CharField(label="Bio", widget=forms.TextInput(attrs={'placeholder':'something interesting about you'})) 

을 변경 수정하고 메타

에서 레이블 목록을 삭제하려면 여기 코드입니다