Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed ManyToOne to ManyToOneRel to be consistent with ManyToManyRel

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2649 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b8d8aca5fd810cd5906d382e5d2c6d04ed63dffb 1 parent e3e271f
@adrianholovaty adrianholovaty authored
View
4 django/contrib/admin/templatetags/admin_list.py
@@ -87,7 +87,7 @@ def result_headers(cl):
# Non-field list_display values don't get ordering capability.
yield {"text": header}
else:
- if isinstance(f.rel, meta.ManyToOne) and f.null:
+ if isinstance(f.rel, meta.ManyToOneRel) and f.null:
yield {"text": f.verbose_name}
else:
th_classes = []
@@ -124,7 +124,7 @@ def items_for_result(cl, result):
else:
field_val = getattr(result, f.attname)
- if isinstance(f.rel, meta.ManyToOne):
+ if isinstance(f.rel, meta.ManyToOneRel):
if field_val is not None:
result_repr = getattr(result, 'get_%s' % f.name)()
else:
View
2  django/contrib/admin/templatetags/admin_modify.py
@@ -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.ManyToManyRel)) \
+ return isinstance(self.field.rel, (meta.ManyToOneRel, meta.ManyToManyRel)) \
and self.field.rel.raw_id_admin
class FormFieldCollectionWrapper(object):
View
12 django/contrib/admin/views/main.py
@@ -174,7 +174,7 @@ def get_ordering(self):
except meta.FieldDoesNotExist:
pass
else:
- if not isinstance(f.rel, meta.ManyToOne) or not f.null:
+ if not isinstance(f.rel, meta.ManyToOneRel) or not f.null:
order_field = f.name
except (IndexError, ValueError):
pass # Invalid ordering specified. Just use the default.
@@ -199,7 +199,7 @@ def get_lookup_params(self):
except meta.FieldDoesNotExist:
pass
else:
- if isinstance(lookup_opts.get_field(order_field).rel, meta.ManyToOne):
+ if isinstance(lookup_opts.get_field(order_field).rel, meta.ManyToOneRel):
f = lookup_opts.get_field(order_field)
rel_ordering = f.rel.to.ordering and f.rel.to.ordering[0] or f.rel.to.pk.column
lookup_order_field = '%s.%s' % (f.rel.to.db_table, rel_ordering)
@@ -214,7 +214,7 @@ def get_lookup_params(self):
except meta.FieldDoesNotExist:
pass
else:
- if isinstance(f.rel, meta.ManyToOne):
+ if isinstance(f.rel, meta.ManyToOneRel):
lookup_params['select_related'] = True
break
lookup_params['order_by'] = ((order_type == 'desc' and '-' or '') + lookup_order_field,)
@@ -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.ManyToManyRel)) and field.rel.raw_id_admin
+use_raw_id_admin = lambda field: isinstance(field.rel, (meta.ManyToOneRel, 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.ManyToManyRel) and field.rel.to.admin
+ self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOneRel) or isinstance(field.rel, meta.ManyToManyRel) and field.rel.to.admin
self.hidden = isinstance(self.field, meta.AutoField)
self.first = False
@@ -307,7 +307,7 @@ def _fill_existing_display(self):
if getattr(self, '_display_filled', False):
return
# HACK
- if isinstance(self.field.rel, meta.ManyToOne):
+ if isinstance(self.field.rel, meta.ManyToOneRel):
func_name = 'get_%s' % self.field.name
self._display = self._fetch_existing_display(func_name)
elif isinstance(self.field.rel, meta.ManyToManyRel):
View
12 django/core/meta/__init__.py
@@ -494,7 +494,7 @@ def get_all_related_objects(self):
# subsequently loaded object with related links will override this
# relationship we're adding.
link_field = copy.copy(relatedlinks.RelatedLink._meta.get_field('object_id'))
- link_field.rel = ManyToOne(self.get_model_module().Klass, 'id',
+ link_field.rel = ManyToOneRel(self.get_model_module().Klass, 'id',
num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR,
lookup_overrides={
'content_type__package__label__exact': self.app_label,
@@ -748,7 +748,7 @@ def __new__(cls, name, bases, attrs):
f.rel.field_name = f.rel.field_name or f.rel.to.pk.name
# Add "get_thingie" methods for many-to-one related objects.
# EXAMPLES: Choice.get_poll(), Story.get_dateline()
- if isinstance(f.rel, ManyToOne):
+ if isinstance(f.rel, ManyToOneRel):
func = curry(method_get_many_to_one, f)
func.__doc__ = "Returns the associated `%s.%s` object." % (f.rel.to.app_label, f.rel.to.module_name)
attrs['get_%s' % f.name] = func
@@ -946,7 +946,7 @@ def __repr__(self):
def method_init(opts, self, *args, **kwargs):
if kwargs:
for f in opts.fields:
- if isinstance(f.rel, ManyToOne):
+ if isinstance(f.rel, ManyToOneRel):
try:
# Assume object instance was passed in.
rel_obj = kwargs.pop(f.name)
@@ -1927,7 +1927,7 @@ def manipulator_flatten_data(opts, klass, add, change, self):
def manipulator_validator_unique_together(field_name_list, opts, self, field_data, all_data):
from django.utils.text import get_text_list
field_list = [opts.get_field(field_name) for field_name in field_name_list]
- if isinstance(field_list[0].rel, ManyToOne):
+ if isinstance(field_list[0].rel, ManyToOneRel):
kwargs = {'%s__%s__iexact' % (field_name_list[0], field_list[0].rel.field_name): field_data}
else:
kwargs = {'%s__iexact' % field_name_list[0]: field_data}
@@ -1940,7 +1940,7 @@ def manipulator_validator_unique_together(field_name_list, opts, self, field_dat
# This will be caught by another validator, assuming the field
# doesn't have blank=True.
return
- if isinstance(f.rel, ManyToOne):
+ if isinstance(f.rel, ManyToOneRel):
kwargs['%s__pk' % f.name] = field_val
else:
kwargs['%s__iexact' % f.name] = field_val
@@ -1962,7 +1962,7 @@ def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_t
if date_val is None:
return # Date was invalid. This will be caught by another validator.
lookup_kwargs = {'%s__year' % date_field.name: date_val.year}
- if isinstance(from_field.rel, ManyToOne):
+ if isinstance(from_field.rel, ManyToOneRel):
lookup_kwargs['%s__pk' % from_field.name] = field_data
else:
lookup_kwargs['%s__iexact' % from_field.name] = field_data
View
14 django/core/meta/fields.py
@@ -47,7 +47,7 @@ def manipulator_valid_rel_key(f, self, field_data, all_data):
def manipulator_validator_unique(f, opts, self, field_data, all_data):
"Validates that the value is unique for this field."
- if f.rel and isinstance(f.rel, ManyToOne):
+ if f.rel and isinstance(f.rel, ManyToOneRel):
lookup_type = '%s__%s__exact' % (f.name, f.rel.get_related_field().name)
else:
lookup_type = '%s__exact' % f.name
@@ -133,7 +133,7 @@ def __init__(self, verbose_name=None, name=None, primary_key=False,
# 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, ManyToOne):
+ if isinstance(rel, OneToOne) or isinstance(rel, ManyToOneRel):
self.db_index = True
else:
self.db_index = False
@@ -152,7 +152,7 @@ def set_name(self, name):
self.attname, self.column = self.get_attname_column()
def get_attname_column(self):
- if isinstance(self.rel, ManyToOne):
+ if isinstance(self.rel, ManyToOneRel):
attname = '%s_id' % self.name
else:
attname = self.name
@@ -222,7 +222,7 @@ def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=
params = {'validator_list': self.validator_list[:]}
if self.maxlength and not self.choices: # Don't give SelectFields a maxlength parameter.
params['maxlength'] = self.maxlength
- if isinstance(self.rel, ManyToOne):
+ if isinstance(self.rel, ManyToOneRel):
params['member_name'] = name_prefix + self.attname
if self.rel.raw_id_admin:
field_objs = self.get_manipulator_field_objs()
@@ -698,7 +698,7 @@ def __init__(self, to, to_field=None, **kwargs):
warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
- kwargs['rel'] = ManyToOne(to, to_field,
+ kwargs['rel'] = ManyToOneRel(to, to_field,
num_in_admin=kwargs.pop('num_in_admin', 3),
min_num_in_admin=kwargs.pop('min_num_in_admin', None),
max_num_in_admin=kwargs.pop('max_num_in_admin', None),
@@ -821,7 +821,7 @@ def __init__(self, to, to_field=None, **kwargs):
kwargs['primary_key'] = True
IntegerField.__init__(self, **kwargs)
-class ManyToOne:
+class ManyToOneRel:
def __init__(self, to, field_name, num_in_admin=3, min_num_in_admin=None,
max_num_in_admin=None, num_extra_on_change=1, edit_inline=False,
related_name=None, limit_choices_to=None, lookup_overrides=None, raw_id_admin=False):
@@ -855,7 +855,7 @@ def __init__(self, to, singular=None, num_in_admin=0, 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(ManyToOne):
+class OneToOne(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):
View
2  django/models/__init__.py
@@ -32,7 +32,7 @@
func = curry(meta.method_get_related, 'get_object', rel_mod, related.field)
func.__doc__ = "Returns the associated `%s.%s` object." % (related.opts.app_label, related.opts.module_name)
setattr(klass, 'get_%s' % rel_obj_name, func)
- elif isinstance(related.field.rel, meta.ManyToOne):
+ elif isinstance(related.field.rel, meta.ManyToOneRel):
# Add "get_thingie" methods for many-to-one related objects.
# EXAMPLE: Poll.get_choice()
func = curry(meta.method_get_related, 'get_object', rel_mod, related.field)
Please sign in to comment.
Something went wrong with that request. Please try again.