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 Main, 18 years ago

Type: enhancementdefect

comment:2 by Gary Wilson <gary.wilson@…>, 17 years ago

Triage Stage: UnreviewedAccepted

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?

comment:3 by Simon Willison, 17 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 mir@…, 17 years ago

Triage Stage: UnreviewedAccepted

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 Philippe Raoult, 17 years ago

Keywords: feature_request added

comment:6 by Collin Anderson, 16 years ago

Component: Metasystemdjango.newforms
Summary: Create an admin-input format string frameworkSingle form field for multiple database fields
Triage Stage: AcceptedUnreviewed

Seems to me this is a newforms limitation.

comment:7 by Collin Anderson, 16 years ago

Cc: cmawebsite@… added

comment:8 by Jacob, 16 years ago

Triage Stage: UnreviewedSomeday/Maybe

comment:9 by mrts, 16 years ago

milestone: post-1.0

Non-essential for 1.0.

comment:10 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:11 by Łukasz Rekucki, 13 years ago

Keywords: feature_request removed
Severity: normalNormal
Type: defectNew feature

comment:12 by anonymous, 13 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 msiedlarek, 13 years ago

Cc: msiedlarek added

Forgot to login. comment:12 is mine.

[edit]

Found django-developers thread. Nevermind.

Last edited 13 years ago by msiedlarek (previous) (diff)

comment:14 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:15 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:16 by Alan Justino da Silva, 12 years ago

Cc: Alan Justino da Silva added

comment:17 by Simon Charette, 12 years ago

Cc: charette.s@… added

comment:18 by Jelko Arnds, 11 years ago

Cc: j.arnds@… added

comment:19 by Carlos Palol, 10 years ago

Cc: carlos.palol@… added

comment:20 by anonymous, 10 years ago

UI/UX: set

comment:21 by anonymous, 10 years ago

UI/UX: unset

comment:22 by loic84, 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 Aymeric Augustin, 10 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top