Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #1600 -- Renamed ManyToMany to ManyToManyRel so people get a cl…

…earer error if they use ManyToMany instead of ManyToManyField

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e3e271ff921ba333f03dafe0306b57c59eb9d7e2 1 parent 0162a3b
Adrian Holovaty adrianholovaty authored
4 django/contrib/admin/templatetags/admin_modify.py
View
@@ -103,7 +103,7 @@ def header_class_attribute(self):
return self.field.blank and ' class="optional"' or ''
def use_raw_id_admin(self):
- return isinstance(self.field.rel, (meta.ManyToOne, meta.ManyToMany)) \
+ return isinstance(self.field.rel, (meta.ManyToOne, meta.ManyToManyRel)) \
and self.field.rel.raw_id_admin
class FormFieldCollectionWrapper(object):
@@ -191,7 +191,7 @@ def auto_populated_field_script(auto_pop_fields, change = False):
def filter_interface_script_maybe(bound_field):
f = bound_field.field
- if f.rel and isinstance(f.rel, meta.ManyToMany) and f.rel.filter_interface:
+ if f.rel and isinstance(f.rel, meta.ManyToManyRel) and f.rel.filter_interface:
return '<script type="text/javascript">addEvent(window, "load", function(e) {' \
' SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % (
f.name, f.verbose_name, f.rel.filter_interface-1, ADMIN_MEDIA_PREFIX)
6 django/contrib/admin/views/main.py
View
@@ -247,7 +247,7 @@ def change_list(request, app_label, module_name):
'admin/change_list'], context_instance=c)
change_list = staff_member_required(change_list)
-use_raw_id_admin = lambda field: isinstance(field.rel, (meta.ManyToOne, meta.ManyToMany)) and field.rel.raw_id_admin
+use_raw_id_admin = lambda field: isinstance(field.rel, (meta.ManyToOne, meta.ManyToManyRel)) and field.rel.raw_id_admin
def get_javascript_imports(opts,auto_populated_fields, ordered_objects, field_sets):
# Put in any necessary JavaScript imports.
@@ -285,7 +285,7 @@ def __init__(self, field, field_mapping, original):
self.raw_id_admin = use_raw_id_admin(field)
self.is_date_time = isinstance(field, meta.DateTimeField)
self.is_file_field = isinstance(field, meta.FileField)
- self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToMany) and field.rel.to.admin
+ self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToManyRel) and field.rel.to.admin
self.hidden = isinstance(self.field, meta.AutoField)
self.first = False
@@ -310,7 +310,7 @@ def _fill_existing_display(self):
if isinstance(self.field.rel, meta.ManyToOne):
func_name = 'get_%s' % self.field.name
self._display = self._fetch_existing_display(func_name)
- elif isinstance(self.field.rel, meta.ManyToMany):
+ elif isinstance(self.field.rel, meta.ManyToManyRel):
func_name = 'get_%s_list' % self.field.rel.singular
self._display = ", ".join([str(obj) for obj in self._fetch_existing_display(func_name)])
self._display_filled = True
2  django/core/management.py
View
@@ -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)
2  django/core/meta/__init__.py
View
@@ -385,7 +385,7 @@ def __init__(self, module_name='', verbose_name='', verbose_name_plural='', db_t
# 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)
8 django/core/meta/fields.py
View
@@ -123,7 +123,7 @@ def __init__(self, verbose_name=None, name=None, primary_key=False,
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 @@ def flatten_data(self, follow, obj=None):
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 @@ def get_related_field(self):
"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 @@ def __init__(self, to, singular=None, num_in_admin=0, related_name=None,
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,
Please sign in to comment.
Something went wrong with that request. Please try again.