magic-removal: Removed get_model_module() call in django.db.models.fields

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1658 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-12-15 00:13:09 +00:00
parent 867fdd5084
commit 8f696be3b7
1 changed files with 6 additions and 6 deletions

View File

@ -39,10 +39,10 @@ string_concat = lazy(string_concat, str)
def manipulator_valid_rel_key(f, self, field_data, all_data): 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"
mod = f.rel.to._meta.get_model_module() klass = f.rel.to
try: try:
mod.get_object(pk=field_data) klass._default_manager.get_object(pk=field_data)
except ObjectDoesNotExist: 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
def manipulator_validator_unique(f, opts, self, field_data, all_data): def manipulator_validator_unique(f, opts, self, field_data, all_data):
@ -821,7 +821,7 @@ class ManyToManyField(Field):
if len(choices_list) == 1: if len(choices_list) == 1:
new_data[self.name] = [choices_list[0][0]] new_data[self.name] = [choices_list[0][0]]
return new_data return new_data
def contribute_to_related_class(self, cls, related): def contribute_to_related_class(self, cls, related):
rel_obj_name = related.get_method_name_part() rel_obj_name = related.get_method_name_part()
setattr(cls, 'get_%s' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_object', rel_class=related.model , rel_field=related.field)) setattr(cls, 'get_%s' % rel_obj_name, curry(cls._get_related_many_to_many, method_name='get_object', rel_class=related.model , rel_field=related.field))
@ -856,8 +856,8 @@ class OneToOneField(IntegerField):
rel_obj_name = related.get_method_name_part() rel_obj_name = related.get_method_name_part()
# Add "get_thingie" methods for one-to-one related objects. # Add "get_thingie" methods for one-to-one related objects.
# EXAMPLE: Place.get_restaurants_restaurant() # EXAMPLE: Place.get_restaurants_restaurant()
setattr(cls, 'get_%s' % rel_obj_name, setattr(cls, 'get_%s' % rel_obj_name,
curry(cls._get_related, method_name='get_object', curry(cls._get_related, method_name='get_object',
rel_class=related.model, rel_field=related.field)) rel_class=related.model, rel_field=related.field))
class ManyToOne: class ManyToOne: