Search code examples
djangodjangoappengine

whats the recommended way of adding the fields to a djangoform object?


whats the recommended way of modifying/adding the fields in a djangoform object i was trying adding a new key to the dictionary obj.base_fields['new_field']='value_of_newfield' but as it turns out that it will be added as a string and not a CharField,that can be worked around but some where down my gut i have this feeling that its not the recommended way ..and i am not talking about obj(intial={'new_field':'value_of_newfield'})


Solution

  • You must add an instance of a form field:

    from django import forms
    obj.base_fields['name_of_field'] = forms.CharField()