Opened 13 years ago
Closed 8 years ago
#16575 closed New feature (duplicate)
Allow specifying custom "empty" values for SelectDateWidget
Reported by: | foobarrior | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | |
Severity: | Normal | Keywords: | SelectDateWidget |
Cc: | nikitamalyavin@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
It is possible to add some extra configurations to SelectDateWidget constructor.
There was a need for me to use custom "empty" value for each field and custom <select> order, not assigned with settings.
And that's what was done. I'm attouching my own version of forms.extras.widgets module.
It just differs in described above functionality and completely backward-compatible.
Also current v1.3 code was looking dirty for me, so most such places were rewritten. Hope this version will get into repository
Attachments (4)
Change History (8)
by , 13 years ago
Attachment: | widgets.py added |
---|
by , 13 years ago
Attachment: | widgets.2.py added |
---|
comment:2 by , 13 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Hi, thanks for the contribution! A bit of cleanup and simple extra features are always welcome.
There are however a couple of issues with the patch:
- Actually, it's not a patch; could you create a diff from the current trunk?
- Make sure there are no leftover prints or other debug-statements.
- Other date widgets fall back to default date formats (see DateInput for example) and it is nice to do the same here.
- The cleanup makes the code crisper, but it also makes the helper functions on top a bit harder to read, could you document them?
- The new features should be documented and check whether there are tests for the widget, if they still work and whether or not they need updating.
comment:3 by , 13 years ago
I made foobarrior's changes into a git diff off of the 1.3.1 trunc with a few other changes including:
- Removal of stray prints and other debug statements.
- Adding _has_changed back in. (Not certain about what to do with this method)
- Consolidated the two helper functions into one and added a docstring.
- Fallback to defaults based on locale
If L10N is False, the changes in this diff make the select widgets order by year, month, day. I'm not sure if this should fall back to US order (d/m/Y) as before, or UTC (Y/m/d).
Tests are still needed and this diff causes a failure in line 92 of FormsExtraTestCase. However, should the test be amended to use UTC or en-US in the event of no L10N?
by , 13 years ago
Attachment: | date_format-select_date_widget.2.diff added |
---|
by , 13 years ago
Attachment: | date_format-select_date_widget.diff added |
---|
comment:4 by , 12 years ago
Version: | 1.3 |
---|
comment:5 by , 8 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Summary: | SelectDateWidget should have possibility to have more custom configurations → Allow specifying custom "empty" values for SelectDateWidget |
Duplicate of #22684. Use SelectDateWidget.empty_label
in Django 1.8+.
the same, only removed pep8 utility's errors and warnings