On Sep 29, 11:40 pm, Julien Phalip <[EMAIL PROTECTED]> wrote: > On Sep 29, 10:46 pm, zvoase <[EMAIL PROTECTED]> wrote: > > > Why not do something like this: > > > class MyForm(forms.ModelForm): > > class Meta: > > fields = { > > 'text': forms.CharField(widget=forms.Textarea(), ...), > > 'other_field': None, > > } > > This syntax would not be completely DRY. If, for example, the model's > 'text' field was optional (blank=True), you would need to explicitly > specify the form field as optional (required=False) as well: > > ... > 'text': forms.CharField(widget=forms.Textarea(), > required=False...), > ... > > By having a separate 'widgets' option you could modify the widgets > independently from anything else. Not only is that DRY but also that > would prevent some potential mistakes.
Also, you can already completely override a field like follows: class MyForm(forms.ModelForm): title = forms.CharField(widget=forms.Textarea(), ...) class Meta: model = Article --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---