1. Luke Plant
  2. django

Commits

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

Renamed OneToOne to OneToOneRel to be consistent with ManyToManyRel

  • Participants
  • Parent commits 3088aa9
  • Branches default

Comments (0)

Files changed (4)

File django/contrib/admin/views/main.py

View file
  • Ignore whitespace
             continue
         opts_seen.append(related.opts)
         rel_opts_name = related.get_method_name_part()
-        if isinstance(related.field.rel, meta.OneToOne):
+        if isinstance(related.field.rel, meta.OneToOneRel):
             try:
                 sub_obj = getattr(obj, 'get_%s' % rel_opts_name)()
             except ObjectDoesNotExist:

File django/core/meta/__init__.py

View file
  • Ignore whitespace
         # Calculate one_to_one_field.
         self.one_to_one_field = None
         for f in self.fields:
-            if isinstance(f.rel, OneToOne):
+            if isinstance(f.rel, OneToOneRel):
                 self.one_to_one_field = f
                 break
         # Cache the primary-key field.
     cursor = db.db.cursor()
     for related in opts.get_all_related_objects():
         rel_opts_name = related.get_method_name_part()
-        if isinstance(related.field.rel, OneToOne):
+        if isinstance(related.field.rel, OneToOneRel):
             try:
                 sub_obj = getattr(self, 'get_%s' % rel_opts_name)()
             except ObjectDoesNotExist:

File django/core/meta/fields.py

View file
  • Ignore whitespace
 
         # Set db_index to True if the field has a relationship and doesn't explicitly set db_index.
         if db_index is None:
-            if isinstance(rel, OneToOne) or isinstance(rel, ManyToOneRel):
+            if isinstance(rel, OneToOneRel) or isinstance(rel, ManyToOneRel):
                 self.db_index = True
             else:
                 self.db_index = False
             warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
             kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
 
-        kwargs['rel'] = OneToOne(to, to_field,
+        kwargs['rel'] = OneToOneRel(to, to_field,
             num_in_admin=kwargs.pop('num_in_admin', 0),
             edit_inline=kwargs.pop('edit_inline', False),
             related_name=kwargs.pop('related_name', None),
         self.raw_id_admin = raw_id_admin
         assert not (self.raw_id_admin and self.filter_interface), "ManyToManyRels may not use both raw_id_admin and filter_interface"
 
-class OneToOne(ManyToOneRel):
+class OneToOneRel(ManyToOneRel):
     def __init__(self, to, field_name, num_in_admin=0, edit_inline=False,
         related_name=None, limit_choices_to=None, lookup_overrides=None,
         raw_id_admin=False):

File django/models/__init__.py

View file
  • Ignore whitespace
             # generated.
             rel_mod = related.opts.get_model_module()
             rel_obj_name = related.get_method_name_part()
-            if isinstance(related.field.rel, meta.OneToOne):
+            if isinstance(related.field.rel, meta.OneToOneRel):
                 # Add "get_thingie" methods for one-to-one related objects.
                 # EXAMPLE: Place.get_restaurants_restaurant()
                 func = curry(meta.method_get_related, 'get_object', rel_mod, related.field)