Opened 19 years ago
Closed 10 years ago
#27 closed New feature (worksforme)
Single form field for multiple database fields
Reported by: | Adrian Holovaty | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | |
Severity: | Normal | Keywords: | |
Cc: | cmawebsite@…, msiedlarek, Alan Justino da Silva, charette.s@…, j.arnds@…, carlos.palol@… | Triage Stage: | Someday/Maybe |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Some admin interfaces would benefit from being able to have multiple fields' worth of data entered in a single field. For example, a field for a sports stat could be entered into a single field as "XX-YY-ZZ", whereas the three values are actually three separate fields in the DB.
Relevant conversation:
<jacobkm> Well, I'm using those aggregate fields for stats where you type something like "3-17" and it gets split into multiple fields. I see there's a CommaSeperatedIntegerField in formfields which would work for this, but there needs to be a way in the datadescriptions to say "this group of fields should be presented as a single field" <django34> The DD will have to provide a format string of some sort <jacobkm> Easy enough <jacobkm> are you thinking of a % format string or a regex? <django34> Not sure... <django34> Probably just % <django34> fields_together = '%(last_name)s, %(first_name)s'
Change History (23)
comment:1 by , 18 years ago
Type: | enhancement → defect |
---|
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 18 years ago
This would be useful for tagging interfaces as well, where you often want to enter multiple tags separated by spaces.
comment:4 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
The stage was 'Unreviewed', but from the history it should be 'Accepted'. Probably a spam-removal-relict ... I haven't looked at the details.
comment:5 by , 17 years ago
Keywords: | feature_request added |
---|
comment:6 by , 17 years ago
Component: | Metasystem → django.newforms |
---|---|
Summary: | Create an admin-input format string framework → Single form field for multiple database fields |
Triage Stage: | Accepted → Unreviewed |
Seems to me this is a newforms limitation.
comment:7 by , 17 years ago
Cc: | added |
---|
comment:8 by , 17 years ago
Triage Stage: | Unreviewed → Someday/Maybe |
---|
comment:11 by , 14 years ago
Keywords: | feature_request removed |
---|---|
Severity: | normal → Normal |
Type: | defect → New feature |
comment:12 by , 14 years ago
I would not tie this kind of information to the Model. What would you say about the following syntax?
class PersonForm(forms.ModelForm): full_name = forms.CharField() class Meta: exclude = ('first_name', 'last_name',) aggregation = { 'full_name': '%(last_name)s, %(first_name)s', }
There would be no 'full_name'
key in PersonForm.cleaned_data
, but 'first_name'
and 'last_name'
. Validation errors (like incompatibility with format string) would be raised for the full_name
field.
comment:13 by , 14 years ago
Cc: | added |
---|
Forgot to login. comment:12 is mine.
comment:16 by , 13 years ago
Cc: | added |
---|
comment:17 by , 13 years ago
Cc: | added |
---|
comment:18 by , 11 years ago
Cc: | added |
---|
comment:19 by , 11 years ago
Cc: | added |
---|
comment:20 by , 11 years ago
UI/UX: | set |
---|
comment:21 by , 11 years ago
UI/UX: | unset |
---|
comment:22 by , 10 years ago
I think this can be trivially implemented with a custom field and with the current public APIs.
Any objection to closing this ticket?
comment:23 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I know there have been some newforms examples where multiple form fields are used for a single database field. Is it just as easy to do the opposite, single form field for multiple database fields?