I have a Django project that is a decent size. I have lots of models and, consequencly, lots of modelForms. With this project, I have upwards of 50-60 forms, each of which have anywhere from 5 to 30 fields (quick math: around 250-500 fields in total).
Now, I want to style all of these forms fields to have a coherent, non-standard, style across my project. I don’t want to leave the standard web style for input fields, drop-down menus, and buttons etc. I know that I can style a single field by using the attrs={'class':'my_class'}. However, that requires me assigning the class to each field of each form. Thus, massively tedious and a lot of repeating.
Given that I have upwards of 500 fields, how should I go about styling all of these fields? It’d be great to be able to change the styling in one spot and have it reflected everywhere.
I was thinking of using jQuery to find all <input> fields and add a CSS class as the page is loaded. However, I can’t help think that there should be an easier, Django-esque way to achieve this.
Any suggestions?
You don’t have to use classes in order to style stuff with css, and jQuery will also not be needed in this case.
Assuming you have some global stylesheet somewhere, you can just do
This will style all the inputs of type text.