Ticket #570: 570.diff

File 570.diff, 1.8 KB (added by Maniac <Maniac@…>, 19 years ago)

Patch

  • django/core/formfields.py

     
    116116            if field.field_name == key:
    117117                if hasattr(field, 'requires_data_list') and hasattr(self.data, 'getlist'):
    118118                    data = self.data.getlist(field.field_name)
     119                elif hasattr(field, 'db_field_name'):
     120                    data = self.data.get(field.db_field_name, None)
    119121                else:
    120122                    data = self.data.get(field.field_name, None)
    121123                if data is None:
     
    300302    html2python = staticmethod(html2python)
    301303
    302304class SelectField(FormField):
    303     def __init__(self, field_name, choices=[], size=1, is_required=False, validator_list=[]):
     305    def __init__(self, field_name, db_field_name=None, choices=[], size=1, is_required=False, validator_list=[]):
    304306        self.field_name = field_name
     307        if db_field_name:
     308            self.db_field_name = db_field_name
    305309        # choices is a list of (value, human-readable key) tuples because order matters
    306310        self.choices, self.size, self.is_required = choices, size, is_required
    307311        self.validator_list = [self.isValidChoice] + validator_list
  • django/core/meta/fields.py

     
    188188                    else:
    189189                        field_objs = [formfields.SelectField]
    190190                    params['choices'] = self.get_choices()
     191                    params['db_field_name'] = self.get_db_column()
    191192        elif self.choices:
    192193            if self.radio_admin:
    193194                field_objs = [formfields.RadioSelectField]
Back to Top