Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15291 closed (fixed)

Alignment issue in changelist

Reported by: Julien Phalip 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: no UI/UX: no

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 Phalip 14 years ago.
15291_changelist_alignment.2.diff (3.0 KB ) - added by Julien Phalip 14 years ago.
Fixed tests

Download all attachments as: .zip

Change History (6)

by Julien Phalip, 14 years ago

by Julien Phalip, 14 years ago

Fixed tests

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

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 by Russell Keith-Magee, 14 years ago

In [15577]:

(The changeset message doesn't reference this ticket)

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