Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8398 closed (worksforme)

Admin lists aren't showing non-field columns in table header

Reported by: Marinho Brandão Owned by: Manuel Saelices
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When declared a method in list_display attribute of a ModelAdmin class, this column header (TH) is shown in result list of change_list_result.html with an error and this make it hidden, as follows:

<th&lt;font color=&#39;red&#39;&gt;header.class_attrib&lt;/font&gt;>

this line must have an {% if %} consistence around header.class_attrib:

{% for header in result_headers %}<th{{ header.class_attrib }}>

Attachments (1)

8398.diff (681 bytes ) - added by Marinho Brandão 16 years ago.

Download all attachments as: .zip

Change History (9)

by Marinho Brandão, 16 years ago

Attachment: 8398.diff added

comment:1 by Jacob, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Manuel Saelices, 16 years ago

Has patch: set

comment:3 by Manuel Saelices, 16 years ago

Owner: changed from nobody to Manuel Saelices
Status: newassigned

comment:4 by Manuel Saelices, 16 years ago

@marinho, I can't reproduce the error. All works fine. Can you give me both models.py and admin.py, please?

I've used this models.py and admin.py:

# models.py
from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=128)

# admin.py
class PersonAdmin(admin.ModelAdmin):
    list_display = ('upper_case_name',)

    def upper_case_name(self, obj):
      return obj.name.upper()
admin.site.register(Person, PersonAdmin)

comment:5 by Ben Spaulding, 16 years ago

I cannot reproduce the error either.

There should be no error because of the way invalid variables are handled. An if statement is unnecessary.

comment:6 by Jacob, 16 years ago

Resolution: worksforme
Status: assignedclosed

comment:7 by kikko, 16 years ago

I just had a similar problem and pinpointed the cause to TEMPLATE_STRING_IF_INVALID. So if you're experiencing a similar problem you should check whether you have TEMPLATE_STRING_IF_INVALID set in your settings.py. (Not a bug since the docs warn that the admin interface expects the setting to be left alone)

comment:8 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top