Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#8398 closed (worksforme)

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

Reported by: marinho Owned by: msaelices
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 6 years ago.

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by marinho

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by msaelices

  • Has patch set

comment:3 Changed 6 years ago by msaelices

  • Owner changed from nobody to msaelices
  • Status changed from new to assigned

comment:4 Changed 6 years ago by msaelices

@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 Changed 6 years ago by benspaulding

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 Changed 6 years ago by jacob

  • Resolution set to worksforme
  • Status changed from assigned to closed

comment:7 Changed 5 years ago by kikko

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 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.