Merry Christmas to you !

Short version: is it possible to define a set of default css classes that 
Django should use whenever rendering a form ?

Long version:
The context is as follows: I would like to use the css classes defined in 
the w3.css framework for all my forms (
http://www.w3schools.com/w3css/default.asp). I have seen that it is 
possible to do that in Django at form class definition or at form 
rendering, but it requires in both cases an explicit declaration of all the 
form fields. That means that I loose all the benefit of automatic form 
generation for ModelForms. I would like something as follows instead:

   1. Define somewhere (e.g. in the settings file) a default mapping 
   between form fields / widgets and css classes, e.g. 'textinput': 
   'my_default_css_class_for_text_inputs'
   2. By default, for all automatic generation and rendering of forms, the 
   default css classes defined in (1) are used, with no or minimal 
   modification of the existing form classes
   3. For specific forms, I can overload the defaults with other values

As far as I've understood, such behaviour is not possible in django. The 
crispy-forms package seems to go in that direction, but it seems to do much 
more than just that, and I am not sure that I want all the extra complexity 
(I'm still a newbie around here). An alternative would be to use javascript 
to add the classes on the client side. It looks ugly to me and prevents 
specific classes to be set for non-default forms.


Could anyone confirm my understanding of this issue and point me towards 
elegant solutions, if any ?


Thanks !


Jonathan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce1ae1d7-7175-41d2-bbee-19793a6536e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to