diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-12-09 01:46:14 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-12-09 01:46:14 +0000 |
| commit | 36f1aef5ff05270462afcc54caddf82f7c4dbbfa (patch) | |
| tree | 1d772754af950ae4b82e4addd474ab697a9d5106 | |
| parent | 4aedb7386a897577a6362fcb0de0f6a8943d3085 (diff) | |
Fixed #927 -- Non-integer primary keys save() method now works
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1569 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/meta/fields.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index c45c7b6e02..71b995a2df 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -720,9 +720,9 @@ class ForeignKey(Field): def get_db_prep_save(self,value): if value == '' or value == None: - return None + return None else: - return int(value) + return self.rel.get_related_field().get_db_prep_save(value) def flatten_data(self, follow, obj = None): if not obj: @@ -731,9 +731,9 @@ class ForeignKey(Field): # the length of choices is *2*, not 1, because SelectFields always # have an initial "blank" value. if not self.blank and not self.rel.raw_id_admin and self.choices: - choice_list = self.get_choices_default() - if len(choice_list) == 2: - return { self.attname : choice_list[1][0] } + choice_list = self.get_choices_default() + if len(choice_list) == 2: + return { self.attname : choice_list[1][0] } return Field.flatten_data(self, follow, obj) class ManyToManyField(Field): |
