mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Replaced '__' with LOOKUP_SEP constant.
This commit is contained in:
		| @@ -11,6 +11,7 @@ from django.contrib.admin.utils import ( | ||||
| from django.core import checks | ||||
| from django.core.exceptions import FieldDoesNotExist | ||||
| from django.db import models | ||||
| from django.db.models.constants import LOOKUP_SEP | ||||
| from django.forms.models import ( | ||||
|     BaseModelForm, BaseModelFormSet, _get_foreign_key, | ||||
| ) | ||||
| @@ -458,7 +459,7 @@ class BaseModelAdminChecks(object): | ||||
|             ] | ||||
|         elif field_name == '?': | ||||
|             return [] | ||||
|         elif '__' in field_name: | ||||
|         elif LOOKUP_SEP in field_name: | ||||
|             # Skip ordering in the format field1__field2 (FIXME: checking | ||||
|             # this format would be nice, but it's a little fiddly). | ||||
|             return [] | ||||
|   | ||||
| @@ -30,7 +30,7 @@ def lookup_needs_distinct(opts, lookup_path): | ||||
|     """ | ||||
|     Returns True if 'distinct()' should be used to query the given lookup path. | ||||
|     """ | ||||
|     lookup_fields = lookup_path.split('__') | ||||
|     lookup_fields = lookup_path.split(LOOKUP_SEP) | ||||
|     # Remove the last item of the lookup path if it is a query term | ||||
|     if lookup_fields[-1] in QUERY_TERMS: | ||||
|         lookup_fields = lookup_fields[:-1] | ||||
|   | ||||
| @@ -6,6 +6,7 @@ from collections import OrderedDict | ||||
|  | ||||
| from django.core.management.base import BaseCommand, CommandError | ||||
| from django.db import DEFAULT_DB_ALIAS, connections | ||||
| from django.db.models.constants import LOOKUP_SEP | ||||
| from django.utils.encoding import force_text | ||||
|  | ||||
|  | ||||
| @@ -189,10 +190,10 @@ class Command(BaseCommand): | ||||
|         if num_repl > 0: | ||||
|             field_notes.append('Field renamed to remove unsuitable characters.') | ||||
|  | ||||
|         if new_name.find('__') >= 0: | ||||
|             while new_name.find('__') >= 0: | ||||
|                 new_name = new_name.replace('__', '_') | ||||
|             if col_name.lower().find('__') >= 0: | ||||
|         if new_name.find(LOOKUP_SEP) >= 0: | ||||
|             while new_name.find(LOOKUP_SEP) >= 0: | ||||
|                 new_name = new_name.replace(LOOKUP_SEP, '_') | ||||
|             if col_name.lower().find(LOOKUP_SEP) >= 0: | ||||
|                 # Only add the comment if the double underscore was in the original name | ||||
|                 field_notes.append("Field renamed because it contained more than one '_' in a row.") | ||||
|  | ||||
|   | ||||
| @@ -1617,7 +1617,7 @@ class Model(six.with_metaclass(ModelBase)): | ||||
|  | ||||
|         # Skip ordering in the format field1__field2 (FIXME: checking | ||||
|         # this format would be nice, but it's a little fiddly). | ||||
|         fields = (f for f in fields if '__' not in f) | ||||
|         fields = (f for f in fields if LOOKUP_SEP not in f) | ||||
|  | ||||
|         # Skip ordering on pk. This is always a valid order_by field | ||||
|         # but is an alias and therefore won't be found by opts.get_field. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user