98👍
✅
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"
}
26👍
Yes, you can. Simply use the label
argument:
class PostForm(forms.ModelForm):
...
video = forms.FileField(label='embed')
or define it inside your Meta
class:
class PostForm(forms.ModelForm):
...
class Meta:
...
labels = {
"video": "embed"
...
}
- [Django]-Django Admin – Specific user (admin) content
- [Django]-Whats the simplest and safest method to generate a API KEY and SECRET in Python
- [Django]-How to stop autopep8 not installed messages in Code
7👍
class Meta:
model = Book
fields = ('title', 'publication_date', 'author', 'price', 'pages','book_type',)
labels = {
'title':'Titulo',
'publication_date':'Data de Publicação',
'author':'Autor',
'price':'Preço',
'pages':'Número de Páginas',
'book_type':'Formato'
}
widgets = {
'title': forms.TextInput(attrs={'class':'form-control'}),
'publication_date': forms.TextInput(attrs={'class':'form-control'}),
'author': forms.TextInput(attrs={'class':'form-control'}),
'price': forms.TextInput(attrs={'class':'form-control'}),
'pages': forms.TextInput(attrs={'class':'form-control'}),
'book_type': forms.TextInput(attrs={'class':'form-control'}),
}
- [Django]-Django development IDE
- [Django]-Django: list all reverse relations of a model
- [Django]-How to check the TEMPLATE_DEBUG flag in a django template?
5👍
An easy way to achieve this without editing the form would be to change the verbose_name
on the model. For the video
field on your model you could change the label on the form from “video” to “embed” like so:
class Post(models.Model)
video = models.UrlField(verbose_name="embed")
# Other fields
- [Django]-"No module named simple" error in Django
- [Django]-How can i set the size of rows , columns in textField in Django Models
- [Django]-Overriding AppConfig.ready()
Source:stackexchange.com