Question

Our front designer (who has very weak programming experience) has trouble using attrs and so on in python code to control how form should look.

Is there a recommended way of separating these concerns?

I've come across a django-crispy-forms but not sure if this is the right tool to achieve the goal.

Was it helpful?

Solution

Your front end guy really shouldn't be modifying python code. Use crispy-forms by all means to provide him with css ids/classes that he needs for specific form elements. It should still be you working with crispy-forms however, as it is not "easier" than modifying field attrs to add a class/id, just more comprehensive and powerful.

You're not using style="" in attrs to write inline CSS right?

Edit: To answer your comment, it really depends what the work the front end guy is doing involves. Is he writing very specific rules for one element at a time? For example "This text input is going to behave differently to every other text input on our site..." or does he just want to modify the css of all password inputs, or all select boxes etc? If it's the latter, he shouldn't have to be going around adding attrs={"class": "select-box"} to every select box widget on every form. IMO it becomes the job of the django dev to make sure that the right class is present for every form field (crispy-forms is good for doing this).

If his work would involve hassling you every 5 minutes asking for a class to be added to field_x and field_y then yes maybe it's best for him to be doing it himself. But in terms of adding id's to specific fields there really is nothing simpler than the standard attrs usage.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top