Skip to content

Django 2.1 gives error due to prefilling list_display_links #220

@BrendaH

Description

@BrendaH

Django: 2.1.7
Admin sortable2: 0.7

I have a special admin page where I do not want anything to be a link to the item because users sorting the content are not necessarily allowed to edit the items that can be sorted.
So, as per the Django docs, I set my settings like this:

    model = WhoIsWhoFunction
    list_display = ['on_whoiswho', 'functionname', ]
    list_display_links = None
    list_editable = ['on_whoiswho']
    sortable_by = []  # Disable sorting on all columns since adminsortable2 will take care of that

And then, to my surprise I get the following error:

<class 'pe.admin.WhoIsWhoFunctionAdmin'>: (admin.E123) The value of 'on_whoiswho' cannot be in both 'list_editable' and 'list_display_links'.

This is caused by the code here:

        if not self.list_display_links:
            self.list_display_links = (self.list_display[0],)

This code was there from the beginning, but why? If a developer thinks list_display_links should be empty, why do you fill it? Except for removing the default order field from that list, it does not seem to be used for anything, so why is it set?

Commenting these lines out solves my problem and does not seem to have a negative effect.
(Changing the order of my list_display fields so a different field than 'on_whoiswho' gets added to list_display_links also removes the error, but that gives me an unwanted link.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions