On Wed, 2009-08-12 at 20:05 -0700, Kevin Henry wrote: [...] > But if you decide to customize the widget, for example: > > class AuthorForm(forms.ModelForm): > name = forms.CharField(widget=forms.TextInput(attrs={'size':80})) > > class Meta: > model = Author > > the form field no longer reflects these model field options (that is, > there is no help text, no default value, and you can't save it blank).
Correct. You told Django that you wanted to specify the field yourself and it believed you. Django cannot know which attributes you intended to leave out and which you wanted inherited, so it does the only possible thing and leaves things entirely in your control. > > This seems like undesirable behavior. At the very least it's > surprising, Well, surprise is in the eye of the participant. As noted above, it would be surprising to a lot of us if it did pick up the attributes because it removes control from the user. The current behaviour isn't illogical. > and should probably be documented here: > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types. Definitely. Please open a ticket (if one doesn't already exist in the documentation component for this) and feel free to attach a patch with some suggested wording. > > I'm fairly new to Django, so unfortunately I'm not sure of the right > way to do this. If all you want to do is change the widget, you can do that in the form's __init__ method by updating self.fields["name"].widget, for example. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---