Thursday 15 April 2010

python - Django creating a form field that's read only using widgets -


My form field looks like the following:

  class FooForm (ModelForm): somefield = Model.Carfild (widget = form.TestinPoint ({atton = {'readonly': 'readonly'}) class meta: model = foo  

with the code as an error like the following Receiving up: init () found an unexpected keyword argument 'widget'

I thought it is legitimate use of a form widget?

You must use a form field and the model field should not be:

  somefield = model.carfield (widget = forms TextInput (attrs = {'readonly': 'readonly'})  

with

  Somefield = forms.CharField (has been replaced with widget = forms.TextInput) Attrs = {'readonly': 'readonly'}))  

This should be corrected.


No comments:

Post a Comment