Templates

This commit is contained in:
2019-11-05 15:08:44 +01:00
parent 95d6b4adee
commit b7aadda74c
29 changed files with 80 additions and 4363 deletions
@@ -1,6 +1,6 @@
from django.utils.version import get_version
VERSION = (2, 2, 6, 'final', 0)
VERSION = (2, 2, 7, 'final', 0)
__version__ = get_version(VERSION)
@@ -8,7 +8,7 @@ class PostgresSimpleLookup(Lookup):
def as_sql(self, qn, connection):
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
params = lhs_params + rhs_params
params = tuple(lhs_params) + tuple(rhs_params)
return '%s %s %s' % (lhs, self.operator, rhs), params
@@ -344,21 +344,21 @@ class Command(BaseCommand):
def describe_operation(operation, backwards):
"""Return a string that describes a migration operation for --plan."""
prefix = ''
is_error = False
if hasattr(operation, 'code'):
code = operation.reverse_code if backwards else operation.code
action = code.__doc__ if code else ''
action = (code.__doc__ or '') if code else None
elif hasattr(operation, 'sql'):
action = operation.reverse_sql if backwards else operation.sql
else:
action = ''
if backwards:
prefix = 'Undo '
if action is None:
if action is not None:
action = str(action).replace('\n', '')
elif backwards:
action = 'IRREVERSIBLE'
is_error = True
else:
action = str(action).replace('\n', '')
is_error = False
if action:
action = ' -> ' + action
truncated = Truncator(action)
@@ -110,13 +110,14 @@ class IndexColumns(Columns):
def __str__(self):
def col_str(column, idx):
try:
col = self.quote_name(column) + self.col_suffixes[idx]
except IndexError:
col = self.quote_name(column)
# Index.__init__() guarantees that self.opclasses is the same
# length as self.columns.
return '{} {}'.format(col, self.opclasses[idx])
col = '{} {}'.format(self.quote_name(column), self.opclasses[idx])
try:
col = '{} {}'.format(col, self.col_suffixes[idx])
except IndexError:
pass
return col
return ', '.join(col_str(column, idx) for idx, column in enumerate(self.columns))
@@ -743,8 +743,12 @@ class Field(RegisterLookupMixin):
if not getattr(cls, self.attname, None):
setattr(cls, self.attname, DeferredAttribute(self.attname))
if self.choices:
setattr(cls, 'get_%s_display' % self.name,
partialmethod(cls._get_FIELD_display, field=self))
if not hasattr(cls, 'get_%s_display' % self.name):
setattr(
cls,
'get_%s_display' % self.name,
partialmethod(cls._get_FIELD_display, field=self),
)
def get_filter_kwargs_for_object(self, obj):
"""