'add help text for OneToOneField
I want to add a help_text to a field in my admin create for a model. I already tried what is suggested here.
models.py:
class Product(models.Model):
name = ...
ean = models.OneToOneField(EANCode, on_delete = models.CASCADE, help_text = "from model, not visible ...")
forms.py:
class ProductAdminForm(forms.ModelForm):
class Meta:
model = Product
fields = '__all__'
help_texts = {"name": "this is visible",
"ean": "this is not visible"}
So I can add a helptext to a CharField but not to a OneToOneField. Why?
Solution 1:[1]
This would be a bit of a workaround, but you can change how the field names show up in the admin by using verbose_name
ean = models.OneToOneField(EANCode, on_delete = models.CASCADE, verbose_name = "EAN - not visible")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Beikeni |
