Something I've noticed that trips up a lot of people, both new Django users and old, is the way the 'default' argument for model fields works; there's a disconnect between what it actually does and what people commonly assume it does, based largely in when the default value is filled in:
1. The way it actually works is that the default value is stuffed into the field in a FormWrapper, so that when you display it it has the value pre-filled. 2. The way people commonly *expect* it to work is that it should fill in the default value "after the fact" if the form is submitted without a value for that field. Pre-filling in the FormWrapper, and then not touching it again, makes logical sense and is good for an application's end users, because it lets them see what value a field will take if they don't do anything to it, but is tricky for developers because it means you can't rely on the default value to save you if you have a required field that you never display to end users (and frustrates *everybody* when it results in a "please correct the errors below" that doesn't show any errors). "Post-filling" the value after submission also makes logical sense, and is better for developers because it means they can specify default values for one or more fields, and then "hide" those fields by leaving them out of end-user displays, but is problematic for the end users because they can't see what the default value will be if they leave the field alone. Doing both a "pre-fill" and a "post-fill" can somewhat alleviate that, but either way we also get into a big can of worms with trying to second-guess the form submission -- did that field get left out because the user intentionally submitted it blank (in which case it should stay blank), or because it was never displayed (in which case it should get the default value)? Personally, I think the way we do it now -- pre-filling the value and then leaving it alone if it comes back blank -- is the better option, and that the developer-related issues can largely be solved by better documentation (i.e., telling people that if they want to "hide" a field but still require it to be filled in, they should give it 'blank=True' and fill in a value in a custom save method), but judging from the fact that it keeps coming up in tickets and on IRC I think we need to settle on exactly what the behavior will be and document it clearly, preferably with examples. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---