From b9e40b14bc6966504da43b8637a83ad1491a877b Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 10 Apr 2006 03:35:56 +0000 Subject: [PATCH] Renamed OneToOne to OneToOneRel to be consistent with ManyToManyRel git-svn-id: http://code.djangoproject.com/svn/django/trunk@2650 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/views/main.py | 2 +- django/core/meta/__init__.py | 4 ++-- django/core/meta/fields.py | 6 +++--- django/models/__init__.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 719189e9a0..3d92a7d949 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -560,7 +560,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current 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: diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 0196ac08b2..49032e7c74 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -410,7 +410,7 @@ class Options: # 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. @@ -1038,7 +1038,7 @@ def method_delete(opts, self): 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: diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index 1f72d4d436..edd1e4313a 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -133,7 +133,7 @@ class Field(object): # 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 @@ -811,7 +811,7 @@ class OneToOneField(IntegerField): 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), @@ -855,7 +855,7 @@ class ManyToManyRel: 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): diff --git a/django/models/__init__.py b/django/models/__init__.py index e6ecd2ccbe..ea0c66f2ae 100644 --- a/django/models/__init__.py +++ b/django/models/__init__.py @@ -26,7 +26,7 @@ for mod in modules: # 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)