Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the column width in the django admin panel

My admin.py looks like this:

class ChangeAdmin(GuardedModelAdmin):
    form = ChangeForm
    search_fields = ('RFC', 'Ticket_Number', 'User_Email', 'Change_Details')
    list_display = ('RFC', 'Ticket_Number', 'User_Requested_Time', 'Start_Time', 'End_Time',
                    'User_Email', 'Line_of_Business', 'Conf_Call_Details', 'Region',
                    'Summary', 'Description', 'Change_Details', 'Site_code', 'Configuration_Item',
                    'Plan_Owner', 'Plan_status', 'Change_Owner', 'Implementer', 'Validator')
    date_hierarchy = 'Start_Time'
    list_select_related = True

As is evident,there are lots of list fields in the table display.This is screwing up the way the data is being shown in the columns..See screenshotenter image description here

How can I resize the column width in the django admin ?

like image 746
Amistad Avatar asked Dec 22 '13 18:12

Amistad


2 Answers

I think you should try this one or this one. The second link worked for me like a charm.

BTW: (this should be a comment, but I'm not 50 rep) how did you achieve this kind of look? I use grappelli but it looks really dumb compared your theme. My users are constantly complaining lack of graphic design in my application ...

like image 83
sDoky Avatar answered Sep 24 '22 07:09

sDoky


admin.py:

class MyClassAdmin(admin.ModelAdmin):

    class Media:
        css = {
            'all': ('fancy.css')
        }

fancy.css:

.column-foo {
    width: 20px;
}

where "foo" is a field name.

Source: https://docs.djangoproject.com/en/3.0/topics/forms/media/

like image 28
gene Avatar answered Sep 22 '22 07:09

gene