Re: Discrepancy involving choices with ModelForm and Form Stuart Laughlin Wed Feb 22 00:00:34 2012
Carl -- Thanks for the feedback! On Feb 21, 7:47 pm, Carl Meyer <[EMAIL PROTECTED]> wrote: > > It's > important that you can get full control at some level - if a blank > option were automatically added to ChoiceFields, how would you propose > that a developer remove it if they didn't want it? > I would propose... my_form_field = forms.ChoiceField(choices=MY_CHOICES, include_blank=False) (Or similar.) > > In any case, this would be a backwards-incompatible change, so it would > need to be a clearcut bugfix to even be considered. I don't think it's > an improvement at all, let alone a clearcut bugfix. > You make a good point about it being backwards-incompatible. Taking that into account, I reckon I would propose that include_blank default to False, and then consider reversing the default in a subsequent release. I would argue that it is an improvement because I suggest (with no tangible evidence whatsoever, granted) that most people want a blank option included in most cases. Furthermore, it's a code smell when your form strategy drives your model code (i.e. this model's ChoiceField choices includes a blank choice because it's used with a Form, whereas this model's ChoiceField choices has no blank choice because it's being used with a ModelForm). I think it's unfortunate when frameworks steer you into an all-or- nothing proposition. One of the reasons I love django is because I believe it avoids all-or-nothings in favor of fine-grained control. This is one small/trivial example where I think django gets it a bit wrong. In terms of making guesses and trying to do the right thing, ModelForm is an 'all' and Form is a 'nothing', at least when it comes to this minor choices issue. At any rate, thanks again for the feedback. Please feel free to interact with anything I've written here. In the meantime, sounds like I ought not bother with a ticket. I'll just include a blank choice myself and get on with it. :) Thanks again, --Stuart -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [EMAIL PROTECTED] 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.
- Discrepancy involving choices with ModelForm and Form Stuart Laughlin 2012/02/21
- Re: Discrepancy involving choices with ModelForm and Form Carl Meyer 2012/02/21
- Re: Discrepancy involving choices with ModelForm and Form Stuart Laughlin 2012/02/22 <=
- Re: Discrepancy involving choices with ModelForm and Form Łukasz Rekucki 2012/02/22