set every single form readonly without using widgets in the model -


i trying build template forms. have model 400 attributes 1 entity. want make 2 different templates. in 1 template attributes should listed django form do. in other template attributes should set readonly.

i don't want create 2 diffent forms every attribute using widgets.

cust_form = generaldataform(instance=_customer, auto_id=false, label_suffix='') 

i tried inserting widget here doesn't work.

using code can make form readonly. looking this?

cust_form_read_only = make_form_readonly(cust_form)  def make_form_readonly(form):         name, field in form.fields.items():         field.widget.attrs['readonly'] = true         field.widget.attrs['disabled'] = true     return form 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -