diff options
| author | Dmitry Dygalo <d.dygalo@volsor.com> | 2015-11-08 17:05:45 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-11-17 07:58:49 -0500 |
| commit | 92eced62cdbc0d74567d3b67f8d18d5f4e5603d1 (patch) | |
| tree | 0c508a6d5d06c30dd92063f8f43610fb7c8f2b25 | |
| parent | 02d974ceb5d69c005f76d421b14e248e26a06df7 (diff) | |
Simplified lists creation in three places.
| -rw-r--r-- | django/contrib/admin/widgets.py | 15 | ||||
| -rw-r--r-- | django/core/management/commands/createcachetable.py | 7 | ||||
| -rw-r--r-- | django/db/models/sql/compiler.py | 9 |
3 files changed, 19 insertions, 12 deletions
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 491c78870f..3264355ed6 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -45,12 +45,15 @@ class FilteredSelectMultiple(forms.SelectMultiple): attrs['class'] = 'selectfilter' if self.is_stacked: attrs['class'] += 'stacked' - output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)] - output.append('<script type="text/javascript">addEvent(window, "load", function(e) {') - # TODO: "id_" is hard-coded here. This should instead use the correct - # API to determine the ID dynamically. - output.append('SelectFilter.init("id_%s", "%s", %s); });</script>\n' - % (name, escapejs(self.verbose_name), int(self.is_stacked))) + output = [ + super(FilteredSelectMultiple, self).render(name, value, attrs, choices), + '<script type="text/javascript">addEvent(window, "load", function(e) {', + # TODO: "id_" is hard-coded here. This should instead use the + # correct API to determine the ID dynamically. + 'SelectFilter.init("id_%s", "%s", %s); });</script>\n' % ( + name, escapejs(self.verbose_name), int(self.is_stacked), + ), + ] return mark_safe(''.join(output)) diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py index c1ec4539b6..fc47cea77d 100644 --- a/django/core/management/commands/createcachetable.py +++ b/django/core/management/commands/createcachetable.py @@ -61,8 +61,11 @@ class Command(BaseCommand): index_output = [] qn = connection.ops.quote_name for f in fields: - field_output = [qn(f.name), f.db_type(connection=connection)] - field_output.append("%sNULL" % ("NOT " if not f.null else "")) + field_output = [ + qn(f.name), + f.db_type(connection=connection), + '%sNULL' % ('NOT ' if not f.null else ''), + ] if f.primary_key: field_output.append("PRIMARY KEY") elif f.unique: diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index ea9b3e78b4..9ebb94a6ce 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1082,10 +1082,7 @@ class SQLUpdateCompiler(SQLCompiler): self.pre_sql_setup() if not self.query.values: return '', () - table = self.query.tables[0] qn = self.quote_name_unless_alias - result = ['UPDATE %s' % qn(table)] - result.append('SET') values, update_params = [], [] for field, model, val in self.query.values: if hasattr(val, 'resolve_expression'): @@ -1124,7 +1121,11 @@ class SQLUpdateCompiler(SQLCompiler): values.append('%s = NULL' % qn(name)) if not values: return '', () - result.append(', '.join(values)) + table = self.query.tables[0] + result = [ + 'UPDATE %s SET' % qn(table), + ', '.join(values), + ] where, params = self.compile(self.query.where) if where: result.append('WHERE %s' % where) |
