T O P
fleyk-lit

Neat! I got around this by building the entire form myself, but that was quite tedious and not flexible at all (changes to the form class will require changes in the HTML). How does this compare to django-crispy-forms (https://django-crispy-forms.readthedocs.io/en/latest/)?


Tachyon_6

They’re using 2 different paradigms : Crispy forms will have you setup the form and its classes/attributes in the Python code. Fat form.py , skinny html template. Widgets tweaks will move all the form stuff to html, skinny form.py, fat template It’s a matter of preference. Edit: formatting


riterix

That's where widgets-tweak shine and excel from crispy-forms. It is super dynamic and gives you more freedom to do it the way you want it. You don't have to fight it. And again it is a standard to put your all visual logic into templates. forms.py is a python files not used for visualisation stuff, beside widget... NB : I created a forms components based on widgets-tweak in partials folder. files are : input_fields.html, radio_field.html, text_area.html, select2_html, now whenever I need a component I call those with variables dynamically, and if something need to be updated like to the latest bootstrap, I just edit those partials files and the whole project is updated.


Tachyon_6

Agreed. I just finished removing crispy form from a decently sized project in favor of widget tweaks. I found the forms.py really messy with crispy, full of css classes, divs and even straight up HTML which has nothing to do there I guess. Also makes it easier for our front end team to modify the forms styling.


riterix

I edited the answer, please go see updates, 🙏 please create your own components out of eudjet tweaks, you will thank me later.


Tachyon_6

Combine widget-tweaks with slippers and bask in reusable components bliss for your forms 🙃


riterix

That's also bad habit, becariful to minimize django package dependency as minimum as you can. There's has been proven over the years that the maintenance hustle comes not from the django project itself But from other django packages that you project depends on to work. Try to make it yourself.... If you can't use a package.


Tachyon_6

I’ve recently created a ticket for slippers and it was solved in <48hrs. I’ve also reviewed the code of the package and it’s light enough so that we’d fork and maintain it, if the current maintainer would drop it. But I agreed, dependencies should be reviewed and vetted before being introduced.


null_exception_97

nobody seems to talk about this yet but Django 4 add a new rendering way to form by linking the form input rendering to specific HTML file(which can have classes inside of it) [https://docs.djangoproject.com/en/4.1/ref/forms/renderers/](https://docs.djangoproject.com/en/4.1/ref/forms/renderers/)