Finally , I got it.
class ItemForm(ModelForm):
item = forms.CharField(label='Item')
class Meta:
model=Item
def __init__(self, *args, **kwargs):
super(ItemForm, self).__init__(*args, **kwargs)
if kwargs.has_key('instance'):
del self.fields['item']
There is an error in code above.
I forgot to write to message the call to super.
Here is the code I'm trying to work
http://dpaste.com/375663/
Thanks in advance for any help
On 1 fev, 17:48, andmart wrote:
> Hi all,
>
> I'm trying to remove or add fields based in presence
Hi all,
I'm trying to remove or add fields based in presence of 'instance'
parameter in ModelForm __init__ like this:
class ItemForm(ModelForm):
class Meta:
model = Item
def __init__(self, *args, **kwargs):
if not kwargs.has_key('instance'):
3 matches
Mail list logo