Reputation: 62
I'm new to Django. After few weeks learning, I've designed my form layout inside forms.py, like this:
But it's quite annoying when I have to write html tag in string format without IDE styling, So do you guys have any ideas to design form layout in Django that is more clear and easy to maintain? I'm using crispy_forms btw. Thank you...
Upvotes: 0
Views: 255
Reputation: 2383
It's not bad as there are no ways to tell whether practices are good or bad as they're mostly up to personal flavor. My take, however, is that crispy forms do not provide enough flexibility. Plus, once you moved on to complex form controls, you need multiple divisions and the hierarchy will be stacked.
It's up to you whether you want to keep this, but I'll tell you how I get past the forms.
{{ form.as_p }}
. I include the action, URL, and then apply my custom form but use the id, name, and everything else that the default form uses.So you'll have the same Django field attributes but they are applied to your custom HTML form. It's definitely more work, but from my experience, this pays off.
Upvotes: 1