On Sat, 2009-02-21 at 20:38 -0800, rajeesh wrote: > > Well, Let me re-phrase that question: I'm currently using the > following line of code to populate text_input fields in the custom > form: > form.base_fields['r_date'].widget.attrs['value'] = > obj.transaction.trans_date > But is this acceptable way of coding?
Where are you doing this? In the form's __init__ method? If so, don't ever touch base_fields, only work with self.fields. If you're only intending to populate the initial data for a particular form field, then usually you would do just that: self.fields[<field_name>].initial = .... Or you could update the form's initial data dictionary: self.initial_data[<field_name>] = ... When the field is rendered the initial data value will be passed through to the widget correctly. > If yes, how can I populate > ChoiceFields? Depends upon how you're using them. You've provided no details. How about spending five minutes to create a simple model and form demonstrating what you're trying to do? Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---