Field Labels Crispy Django Shapes

I want to use the same model for two forms and change the field labels, how can I change the label?

this is my only form:

class jobpostForm(forms.ModelForm):

    class Meta:

        model = jobpost
        fields = ('job_type','title','company_name','location','country','description','start_date','end_date','how_to_apply')

    widgets = {

        'job_type':RadioSelect(),    
        'location':TextInput(attrs={'size':'70','cols': 10, 'rows': 20}),   
        'description': TinyMCE(attrs={'cols':'100', 'row': '80'}),
            'start_date':AdminDateWidget(attrs={'readonly':'readonly'}),
            'end_date':AdminDateWidget(attrs={'readonly':'readonly'}),
            'how_to_apply':RadioSelect(),

    }

    def __init__(self, *args, **kwargs):
        super(jobpostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'horizontal-form'
        self.helper.form_id = 'id-jobpostform'
        self.helper.form_class = 'blueForms'
        self.helper.form_method = 'post'

        self.helper.form_action = '/portal/next/post/'

        self.helper.add_input(Submit(_('submit_addcontent'), 'Preview'))


        super(jobpostForm, self).__init__(*args, **kwargs)

how do I want to change "location" to "Job Location". How can i do this?

+5
source share
1 answer

This issue is not very specific to Django Crispy Forms.

One option is to set a label in init()your method JobPostForm.

def __init__(self, *args, **kwargs):
    super(JobPostForm, self).__init__(*args, **kwargs)
    self.fields['location'].label = "Job Location"

A good indicator when considering such issues is Django Form Overloading .

+13
source

All Articles