Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List report giving key error #95

Open
gocamiot opened this issue Oct 25, 2023 · 0 comments
Open

List report giving key error #95

gocamiot opened this issue Oct 25, 2023 · 0 comments

Comments

@gocamiot
Copy link

So when I run this report:
class ListOfDevicesNow(ReportView):
#report_title = _("List of devices")
report_model = device_view
report_title = "List of devices"
date_field = "import_date"
filters = ["Name"]
columns = [
"Name",
"Model",
"SerialNumber",
"ConnectionState",
"OsVerTxt",
"User",
"LastBootUtc",
"LastConnUtc",
"CreatedUtc",
"id",
]
default_order_by = "-id"
limit_records = 10

Table has data in.
I get this error on server console:
Takes a list of dicts, returns that list sorted by the property given in', ' the argument.', ' """'], 'context_line': ' return sorted(value, key=lambda x: x[arg], reverse=desc)', 'post_context': ['', '', 'class ExportToCSV(object):', ' def get_filename(self):',
' return self.report_title', ''], 'pre_context_lineno': 28, 'colno': '', 'tb_area_colno': ''}}]
Internal Server Error: /list-of-devices-now/
....
grc\slick_reporting\views.py", line 35, in
return sorted(value, key=lambda x: x[arg], reverse=desc)
KeyError: 'id'

Which leads to this code:
def dictsort(value, arg, desc=False):
"""
Takes a list of dicts, returns that list sorted by the property given in
the argument.
"""
return sorted(value, key=lambda x: x[arg], reverse=desc)

Can you please give me some direction?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant