magic-removal: Fixed bug in calling of manipulator_valid_rel_key()

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1940 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-13 04:54:25 +00:00
parent a9297c7a5d
commit e31e75c736
2 changed files with 9 additions and 9 deletions

View File

@ -24,14 +24,6 @@ prep_for_like_query = lambda x: str(x).replace("%", "\%").replace("_", "\_")
# returns the <ul> class for a given radio_admin value
get_ul_class = lambda x: 'radiolist%s' % ((x == HORIZONTAL) and ' inline' or '')
def manipulator_valid_rel_key(f, self, field_data, all_data):
"Validates that the value is a valid foreign key"
klass = f.rel.to
try:
klass._default_manager.get_object(pk=field_data)
except klass.DoesNotExist:
raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name
def manipulator_validator_unique(f, opts, self, field_data, all_data):
"Validates that the value is unique for this field."
lookup_type = f.get_validator_unique_lookup_type()

View File

@ -3,7 +3,7 @@ from django.db.models.fields import AutoField, Field, IntegerField
from django.db.models.related import RelatedObject
from django.utils.translation import gettext_lazy, string_concat
from django.utils.functional import curry
from django.core import formfields
from django.core import formfields, validators
from django.dispatch import dispatcher
# Values for Relation.edit_inline.
@ -28,6 +28,14 @@ def do_pending_lookups(sender):
dispatcher.connect(do_pending_lookups, signal=signals.class_prepared)
def manipulator_valid_rel_key(f, self, field_data, all_data):
"Validates that the value is a valid foreign key"
klass = f.rel.to
try:
klass._default_manager.get_object(pk=field_data)
except klass.DoesNotExist:
raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name
#HACK
class RelatedField(object):
def contribute_to_class(self, cls, name):