how can I change the modelform label and give it a custom name

前端 未结 4 548
慢半拍i
慢半拍i 2020-12-29 19:23

I want to create a custom name for on of the labels in my modelform this is my forms.py

class PostForm(forms.ModelForm):
    body = forms.CharField(widget=Pa         


        
4条回答
  •  死守一世寂寞
    2020-12-29 20:13

    From the documentation:

    You can specify the labels, help_texts and error_messages attributes of the inner Meta class if you want to further customize a field.

    There are examples just below that section of the docs. So, you can do:

    class Meta:
        model = Post
        labels = {
            "video": "Embed"
        }
    

提交回复
热议问题