Skip to content

Instantly share code, notes, and snippets.

@caramelchocolate
Created June 4, 2019 06:49
Show Gist options
  • Save caramelchocolate/61692a26ee48d050f711b55e7af443fe to your computer and use it in GitHub Desktop.
Save caramelchocolate/61692a26ee48d050f711b55e7af443fe to your computer and use it in GitHub Desktop.
adminの入力項目のラベル・エラーメッセージなど
# ref: https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/#overriding-the-default-fields
from django import forms
class fooForm(forms.ModelForm):
class Meta:
model = foo
fields = ('name',)
labels = {
'name': 'なまえ',
}
help_texts = {
'name': 'いいかんじのなまえをいれてね',
}
error_messages = {
'name': {
'max_length': "なまえがながいよ",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment