Django - how to not loose verbose_name and other attributes of Field when overriding its form in ModelForm?
Question: Given:

    
    
    #models.py
    from django.db import models
    
    
    class MyModel(models.Model):
        myfield = models.IntegerField('Detailed description')
    
    #forms.py
    from django import forms
    from models import MyModel
    
    class MyModelForm(forms.ModelForm):
        myfield = forms.IntegerField()
    
    
    class Meta:
        model = MyModel
    

With this setup - verbose_name will not be shown on admin page, name of field
will be instead (with capitalized first letter). If remove overriding field
from MyModelForm - verbose name will be shown as usual. If provide string with
description as argument `label`, `forms.IntegerField()` \- it will be
displayed on admin page.  
Im looking for pythonic way to display verbose_name defined in model class in
case if this field form is overrided in ModelForm, without using `label` hint.

Any thoughts?


Answer: You can access the verbose name of the model in the form like this:

    
    
    myfield = models.IntegerField(label=MyModel._meta.get_field_by_name('myfield')[0].verbose_name)
    

