Fixed bug in manipulator_valid_rel_key -- it assumed the related object was related by the primary-key field, whereas this didn't work with ForeignKeys to non-primary-key fields

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3338 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-07-13 21:31:53 +00:00
parent 36e4e5a938
commit 0a2e8daaaf
1 changed files with 8 additions and 8 deletions

View File

@ -46,7 +46,7 @@ def manipulator_valid_rel_key(f, self, field_data, all_data):
"Validates that the value is a valid foreign key" "Validates that the value is a valid foreign key"
klass = f.rel.to klass = f.rel.to
try: try:
klass._default_manager.get(pk=field_data) klass._default_manager.get(**{f.rel.field_name: field_data})
except klass.DoesNotExist: except klass.DoesNotExist:
raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name