Changeset 1575
- Timestamp:
- 12/08/05 20:25:17 (3 years ago)
- Files:
-
- django/trunk/django/core/meta/fields.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/meta/fields.py
r1573 r1575 728 728 if not obj: 729 729 # In required many-to-one fields with only one available choice, 730 # select that one available choice. Note: We have to check that 731 # the length of choices is *2*, not 1, because SelectFields always 732 # have an initial "blank" value. 733 if not self.blank and not self.rel.raw_id_admin and self.choices: 730 # select that one available choice. Note: For SelectFields 731 # (radio_admin=False), we have to check that the length of choices 732 # is *2*, not 1, because SelectFields always have an initial 733 # "blank" value. Otherwise (radio_admin=True), we check that the 734 # length is 1. 735 if not self.blank and (not self.rel.raw_id_admin or self.choices): 734 736 choice_list = self.get_choices_default() 735 if len(choice_list) == 2: 737 if self.radio_admin and len(choice_list) == 1: 738 return {self.attname: choice_list[0][0]} 739 if not self.radio_admin and len(choice_list) == 2: 736 740 return {self.attname: choice_list[1][0]} 737 741 return Field.flatten_data(self, follow, obj)
