adr...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed f9a0a50

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

  • Participants
  • Parent commits 3a5a88c

Comments (0)

Files changed (5)

File django/contrib/admin/templatetags/

         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):
 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.verbose_name, f.rel.filter_interface-1, ADMIN_MEDIA_PREFIX)

File django/contrib/admin/views/

                                '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.
         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
+        self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToManyRel) and
         self.hidden = isinstance(self.field, meta.AutoField)
         self.first = False
         if isinstance(self.field.rel, meta.ManyToOne):
              func_name = 'get_%s' %
              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

File django/core/

                     except meta.FieldDoesNotExist:
                         e.add(opts, '"unique_together" refers to %s, a field that doesn\'t exist. Check your syntax.' % field_name)
-                        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.' %
     return len(e.errors)

File django/core/meta/

         # 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):

File django/core/meta/

         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.'))
 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),
         "Returns the Field in the 'to' object to which this relationship is tied."
-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): = to._meta
         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,