Skip to content

Commit

Permalink
Fix #115 - stop shadowing the context processor's config variable whe…
Browse files Browse the repository at this point in the history
…n rendering the admin change list.
  • Loading branch information
jezdez committed Oct 1, 2015
1 parent a005625 commit c82d76f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions constance/admin.py
Expand Up @@ -121,7 +121,7 @@ def changelist_view(self, request, extra_context=None):
)
return HttpResponseRedirect('.')
context = {
'config': [],
'config_values': [],
'title': _('Constance config'),
'app_label': 'constance',
'opts': Config._meta,
Expand All @@ -134,15 +134,15 @@ def changelist_view(self, request, extra_context=None):
# Then if the returned value is None, get the default
if value is None:
value = getattr(config, name)
context['config'].append({
context['config_values'].append({
'name': name,
'default': localize(default),
'help_text': _(help_text),
'value': localize(value),
'modified': value != default,
'form_field': form[name],
})
context['config'].sort(key=itemgetter('name'))
context['config_values'].sort(key=itemgetter('name'))
request.current_app = self.admin_site.name
# compatibility to be removed when 1.7 is deprecated
extra = {'current_app': self.admin_site.name} if VERSION < (1, 8) else {}
Expand Down
2 changes: 1 addition & 1 deletion constance/templates/admin/constance/change_list.html
Expand Up @@ -60,7 +60,7 @@
<th><div class="text">{% trans "Is modified" %}</div></th>
</tr>
</thead>
{% for item in config %}
{% for item in config_values %}
<tr class="{% cycle 'row1' 'row2' %}">
<th>{{ item.name }}
<div class="help">{{ item.help_text|linebreaksbr }}</div>
Expand Down
13 changes: 13 additions & 0 deletions tests/settings.py
Expand Up @@ -83,7 +83,20 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'constance.context_processors.config',
],
},
},
]

TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'constance.context_processors.config',
)

0 comments on commit c82d76f

Please sign in to comment.