views:

178

answers:

1

Hi,

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

+2  A: 

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

Daniel Roseman
so what would i need to type. for example if I wanted to remove the field 'name' from the modelform
John
`if 'name' in self.fields: del self.fields['name']`
KillianDS