Django 1.8. I've got model:
class Location(models.Model):
address = models.CharField(max_length=65)
annotation = models.CharField(
max_length=80, verbose_name='Additional info', blank=True, null=True,
help_text='e.g. officce 412, 4 floor')
And I have task to expand form input field a bit for Location
in admin.py
. I made this by:
class LocationAdminForm(forms.ModelForm):
annotation = forms.CharField(
widget=forms.widgets.TextInput(attrs={'size': 70}))
and here I lost my verboose_name
, blank=True
and help_text
in admin form. I can fix this problem by:
class LocationAdminForm(forms.ModelForm):
annotation = forms.CharField(
required=not Location._meta.get_field('annotation').blank,
label=Location._meta.get_field('annotation').verbose_name,
help_text=Location._meta.get_field('annotation').help_text,
widget=forms.widgets.TextInput(attrs={'size': 70}))
but this variant looks so ugly... Are there any other alternatives here?