diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 1634d7d..ade5ddb 100644
a
|
b
|
class ManyToManyField(RelatedField, Field):
|
1049 | 1049 | break |
1050 | 1050 | return getattr(self, cache_attr) |
1051 | 1051 | |
1052 | | def isValidIDList(self, field_data, all_data): |
1053 | | "Validates that the value is a valid list of foreign keys" |
1054 | | mod = self.rel.to |
1055 | | try: |
1056 | | pks = map(int, field_data.split(',')) |
1057 | | except ValueError: |
1058 | | # the CommaSeparatedIntegerField validator will catch this error |
1059 | | return |
1060 | | objects = mod._default_manager.in_bulk(pks) |
1061 | | if len(objects) != len(pks): |
1062 | | badkeys = [k for k in pks if k not in objects] |
1063 | | raise exceptions.ValidationError( |
1064 | | ungettext("Please enter valid %(self)s IDs. The value %(value)r is invalid.", |
1065 | | "Please enter valid %(self)s IDs. The values %(value)r are invalid.", |
1066 | | len(badkeys)) % { |
1067 | | 'self': self.verbose_name, |
1068 | | 'value': len(badkeys) == 1 and badkeys[0] or tuple(badkeys), |
1069 | | }) |
1070 | | |
1071 | 1052 | def value_to_string(self, obj): |
1072 | 1053 | data = '' |
1073 | 1054 | if obj: |