Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django forms exclude fields on init rather than in the meta class

I want to exclude certain fields in the init function of a modelform depending on a parameter passed in, how do I do this? I know I can add exclude fields using the meta class of a model form but I need this to be dynamic depending on the variable passed in.

Thanks

like image 319
John Avatar asked May 13 '10 11:05

John


1 Answers

You can modify the self.fields list after calling super.

like image 53
Daniel Roseman Avatar answered Sep 23 '22 20:09

Daniel Roseman