Question

I'm creating a crispy form from a DB model.

I'd like to put ALL fields from the model in my div helper... Is there a way to do it so that I don't need to write down every single one of them... like:

self.helper.layout = Layout(
   Div('field1', 'field2', 'field3', ...), 
   ...
)

I tried

Div('*')

and things like that but it didn't work.

Any suggestions?

Thanks!

Ron

Was it helpful?

Solution

I found something in the doc...

I think its the solution... :)

render_unmentioned_fields = False By default django-crispy-forms renders the layout specified if it exists strictly, which means it only renders what the layout mentions, unless your form has Meta.fields and Meta.exclude defined, in that case it uses them. If you want to render unmentioned fields in the layout, for example if you are worried about forgetting mentioning them you have to set this property to True. It defaults to False.

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