sixovov947
sixovov947

Reputation: 215

How to get field name from model in django forms?

I have a form and need to change its field name with model value !

I have a model named "Documents" and it has two fields "type and path" ! Now am using model form to create the form

My question is when i display the form, the label of "path" is just "Path" but i need to change that to "type".

Upvotes: 0

Views: 402

Answers (1)

nigel222
nigel222

Reputation: 8202

class MyForm( models.ModelForm):
    class Meta:
        fields=['type', 'path', ]
        labels={'path':'type', }  
        # which will be Extremely Confusing, but you did ask...

Upvotes: 1

Related Questions