1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #1600 -- Renamed ManyToMany to ManyToManyRel so people get a clearer error if they use ManyToMany instead of ManyToManyField

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2006-04-10 03:32:38 +00:00
parent 0162a3b54f
commit e3e271ff92
5 changed files with 11 additions and 11 deletions

View File

@@ -781,7 +781,7 @@ def get_validation_errors(outfile):
except meta.FieldDoesNotExist:
e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name)
else:
if isinstance(f.rel, meta.ManyToMany):
if isinstance(f.rel, meta.ManyToManyRel):
e.add(opts, '"unique_together" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)
return len(e.errors)

View File

@@ -385,7 +385,7 @@ class Options:
# Move many-to-many related fields from self.fields into self.many_to_many.
self.fields, self.many_to_many = [], []
for field in (fields or []):
if field.rel and isinstance(field.rel, ManyToMany):
if field.rel and isinstance(field.rel, ManyToManyRel):
self.many_to_many.append(field)
else:
self.fields.append(field)

View File

@@ -123,7 +123,7 @@ class Field(object):
self.radio_admin = radio_admin
self.help_text = help_text
self.db_column = db_column
if rel and isinstance(rel, ManyToMany):
if rel and isinstance(rel, ManyToManyRel):
if rel.raw_id_admin:
self.help_text = string_concat(self.help_text,
gettext_lazy(' Separate multiple IDs with commas.'))
@@ -742,7 +742,7 @@ class ForeignKey(Field):
class ManyToManyField(Field):
def __init__(self, to, **kwargs):
kwargs['verbose_name'] = kwargs.get('verbose_name', to._meta.verbose_name_plural)
kwargs['rel'] = ManyToMany(to, kwargs.pop('singular', None),
kwargs['rel'] = ManyToManyRel(to, kwargs.pop('singular', None),
num_in_admin=kwargs.pop('num_in_admin', 0),
related_name=kwargs.pop('related_name', None),
filter_interface=kwargs.pop('filter_interface', None),
@@ -842,7 +842,7 @@ class ManyToOne:
"Returns the Field in the 'to' object to which this relationship is tied."
return self.to.get_field(self.field_name)
class ManyToMany:
class ManyToManyRel:
def __init__(self, to, singular=None, num_in_admin=0, related_name=None,
filter_interface=None, limit_choices_to=None, raw_id_admin=False):
self.to = to._meta
@@ -853,7 +853,7 @@ class ManyToMany:
self.limit_choices_to = limit_choices_to or {}
self.edit_inline = False
self.raw_id_admin = raw_id_admin
assert not (self.raw_id_admin and self.filter_interface), "ManyToMany relationships may not use both raw_id_admin and filter_interface"
assert not (self.raw_id_admin and self.filter_interface), "ManyToManyRels may not use both raw_id_admin and filter_interface"
class OneToOne(ManyToOne):
def __init__(self, to, field_name, num_in_admin=0, edit_inline=False,