Display multiple fields on the same line

In the documentation about Django’s Admin site I read:

To display multiple fields on the same line, wrap those fields in their own tuple.

Is this feature also available for forms?

I tried:

class HeroForm(forms.ModelForm):
    class Meta:
        model = models.Hero
        fields = (
            'headline',
            'sub_headline',
            ('btn_cta',  'btn_link'),
            'active',
        )

But that results in a TypeError.

TypeError: sequence item 0: expected str instance, tuple found

Kind regards,

Johanna

By using a definition for fields within the Meta class, no.

However, you have multiple ways to handle the formatting of fields within your forms.

See Working with forms | Django documentation | Django for some ideas to get started, and also take a look at Forms have never been this crispy — django-crispy-forms 2.0 documentation. (We rely heavily upon Crispy Forms)