That would hide the field called 'itemid' from the model 'News'. Are
you saying it doesn't?
Cheers
Tom
Have you simplified your example? This functionality works well when
used correctly:
>>> class TestForm(ModelForm):
... range = CharField(widget=HiddenInput)
... class Meta:
... model=Foo
...
>>> f=TestForm()
>>> f.as_p()
u'<p><label for="id_name">Name:</label> <input type="text" name="name"
id="id_name" /><input type="hidden" name="range" id="id_range" /></p>'
As you can see, the range field is clearly hidden.
Cheers
Tom
Well, in the console I cannot be arsed to continually type
forms.SomeThing, so I imported * from django.forms, but this is
largely irrelevant.
You still haven't shown that it doesn't hide the field, eg by posting
the output of frm.as_p(), where as I have shown conclusively that it
does, so I think something else is going on here. Are you sure the
field 'itemid' exists on your model?
This is speculation, but I think you don't have a field called itemid
on your model, and so are creating an additional field called itemid,
which is hidden. You display the form, you don't see the new, hidden,
'itemid' field because it is hidden, but you do see your field which
is not called 'itemid', and you then think that the field is not
hidden.
It's not hard to test this, go to your django console, import the
form, instantiate it and call the as_p method. Do you have a hidden
field called 'itemid' or not?
Cheers
Tom