default form values (not just initial)
|Reported by:||clime||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I am finding the "initial" functionality on forms lacking.
With this form:
class Form(forms.Form): name = forms.CharField(required=False, initial='Hello world')
If in view, I do something like:
form = Form(request.GET) if form.is_valid(): name = form.cleaned_data['name']
Then initial value of name is lost even if request.GET does not contain name as key.
Why there is not just "default" attribute that would maintain the default value until being explicitly overwritten by request data? There are so few things I find inconvenient in Django but this is one of them.
Change History (5)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
|Status:||new → closed|