Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15291 closed (fixed)

Alignment issue in changelist

Reported by: julien Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This is a different issue than #15290 so I preferred to create a new ticket. This one is quite minor though.

Try this example:

from django.db import models

class MyModel(models.Model):
    name = models.CharField(max_length=100, blank=True)
    title = models.CharField(max_length=100, blank=True)
    content = models.CharField(max_length=100, blank=True)

Admin:

from django.contrib import admin

from .models import MyModel

class MyModelAdmin(admin.ModelAdmin):
    list_display = ('name', 'title', 'content')
    actions = None
    list_display_links = ('title',)

admin.site.register(MyModel, MyModelAdmin)

The content of the first column is centered and not left-aligned like all the other columns are. This is dictated by the CSS, presumably because generally the action checkbox is in the first column, and that needs to be centered.

The attached patch fixes this (minor) issue, though there might be other, more general, approaches to this - perhaps by allowing a callable to provide its own classes? For example, in ModelAdmin.action_checkbox:

    def action_checkbox(self, obj):
        """
        A list_display column containing a checkbox widget.
        """
        return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, force_unicode(obj.pk))
    action_checkbox.short_description = mark_safe('<input type="checkbox" id="action-toggle" />')
    action_checkbox.allow_tags = True
    action_checkbox.css_classes = ['action-checkbox']

Attachments (2)

15291_changelist_alignment.diff (1.1 KB) - added by julien 4 years ago.
15291_changelist_alignment.2.diff (3.0 KB) - added by julien 4 years ago.
Fixed tests

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by julien

Changed 4 years ago by julien

Fixed tests

comment:1 Changed 4 years ago by russellm

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

comment:2 Changed 4 years ago by russellm

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

In [15573]:

Fixed #15291 -- Corrected alignment issue when actions are disabled in a ModelAdmin. Thanks to Julien Phalip for the report and patch.

comment:4 Changed 4 years ago by russellm

In [15577]:

[1.2.X] Fixed #15291 -- Corrected alignment issue when actions are disabled in a ModelAdmin. Thanks to Julien Phalip for the report and patch.

Backport of r15573 from trunk.

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