Ask Your Question

How to add data to tables in horizon Dashboard

asked 2013-05-24 09:20:49 -0600

Leonardo Afonso gravatar image

updated 2013-05-24 17:14:19 -0600

smaffulli gravatar image


I'm trying add some data in tables in a panel that i created, but this data come from a simple method that i develop. This method return a list of strings and i put this method on get_data method on file.

So, when i execute the Horizon an error appears:

Exception Type: TemplateSyntaxError
Exception Value:'str' object has no attribute 'id'
Exception Location:/home/labsc/Documentos/horizon/horizon/tables/ in get_object_id, line 1244

but when i change the list to a empty list o int list, stay normal. the questions is:

How i can return a string list to the tables??

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-05-27 04:33:02 -0600

jpichon gravatar image

Looking at the method mentioned in the error message:

The comment advises overriding this method if you don't want to return an id attribute (which a string wouldn't have).

I would suggest adding something like this to your DataTable:

    def get_object_id(self, datum):
        return datum

and see if this resolves the issue. Note the comment on get_object_id also warns that what you return should be unique for each row -- hopefully your list of strings is made up of unique strings!

edit flag offensive delete link more



Actually it works with non unique keys (like names) but you'll get strange behaviors when trying to delete that objects.

MariusCC gravatar imageMariusCC ( 2013-05-30 04:24:14 -0600 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2013-05-24 09:20:49 -0600

Seen: 781 times

Last updated: May 27 '13