How to change the size of a Django form label

Viewed 309

I have the following form:

forms.py:

from django.forms import ModelForm, HiddenInput, CharField
from django.core.exceptions import ValidationError

import re
from django import forms
from cal.models import Event
from project.models import Project

class EventForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)


    class Meta:
        model = Event
        widgets = {
            'event_type': forms.Select(
                attrs={
                    'size': '4',
                    'style': 'font-size:13px;'
                }
            ),
        }
        labels = {
            'equipments': 'Equipment', 'event_type': 'Type',
        }
        fields = '__all__'

And in my template.html I render the content of the form like this:

    {% bootstrap_field event_form.title layout='horizontal' size='small' %}
    {% bootstrap_field event_form.description layout='horizontal' size='small' %}
    {% bootstrap_field event_form.event_type layout='horizontal' size='small' %}

I would like the label font size to be 13px; Apparently 'style': 'font-size:13px;' works only for the content of the field, not for the label.

Is there a way to add styles only to label or label and field (both)?

I have been reading the documentation here but it is not clear to me how to change the style, it seems like only classes can be changed...?

Any help will be highly appreciated

1 Answers

You can explicitly try to target the control-label class in your CSS file and assign it the CSS properties of your choice.

Related