Code

Opened 9 years ago

Last modified 2 months ago

#27 new New feature

Single form field for multiple database fields

Reported by: adrian Owned by: nobody
Component: Forms Version:
Severity: Normal Keywords:
Cc: cmawebsite@…, msiedlarek, alanjds, 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'

Attachments (0)

Change History (21)

comment:1 Changed 8 years ago by Main

  • Type changed from enhancement to defect

comment:2 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Accepted

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 Changed 7 years ago by Simon Willison

This would be useful for tagging interfaces as well, where you often want to enter multiple tags separated by spaces.

comment:4 Changed 7 years ago by mir@…

  • Triage Stage changed from Unreviewed to 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 Changed 7 years ago by PhiR

  • Keywords feature_request added

comment:6 Changed 6 years ago by CollinAnderson

  • Component changed from Metasystem to django.newforms
  • Summary changed from Create an admin-input format string framework to Single form field for multiple database fields
  • Triage Stage changed from Accepted to Unreviewed

Seems to me this is a newforms limitation.

comment:7 Changed 6 years ago by CollinAnderson

  • Cc cmawebsite@… added

comment:8 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Someday/Maybe

comment:9 Changed 6 years ago by mrts

  • milestone set to post-1.0

Non-essential for 1.0.

comment:10 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:11 Changed 3 years ago by lrekucki

  • Keywords feature_request removed
  • Severity changed from normal to Normal
  • Type changed from defect to New feature

comment:12 Changed 3 years ago by anonymous

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 Changed 3 years ago by msiedlarek

  • Cc msiedlarek added

Forgot to login. comment:12 is mine.

[edit]

Found django-developers thread. Nevermind.

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

comment:14 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:15 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:16 Changed 2 years ago by alanjds

  • Cc alanjds added

comment:17 Changed 2 years ago by charettes

  • Cc charette.s@… added

comment:18 Changed 8 months ago by jelko

  • Cc j.arnds@… added

comment:19 Changed 7 months ago by carlospalol

  • Cc carlos.palol@… added

comment:20 Changed 2 months ago by anonymous

  • UI/UX set

comment:21 Changed 2 months ago by anonymous

  • UI/UX unset

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.