Search code examples
django-formsdjango-viewsdjango-templatesdjango-crispy-forms

Crispy Django Forms


I am Using Crispy form in Django, But now I like to change the text and style in the form of how to do it?

Suppose I like to change the camp Name to the Only Name, the Text is taken from Django Model, But I like to change here and also I want the text should be on left of text field not on top, How to do it


Solution

  • For horizontal forms see the docs here, same rules apply for bootstrap 4.

    https://django-crispy-forms.readthedocs.io/en/latest/crispy_tag_forms.html?highlight=Inline#bootstrap3-horizontal-forms

    To change the fields labels see the django docs

    class AuthorForm(ModelForm): class Meta: model = Author fields = ('name', 'title', 'birth_date') labels = { 'name': 'Writer', }

    https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-fields