Ask Your Question

how to properly extract selected object id from a table

asked 2015-01-20 12:34:47 -0500

eugene.goldberg gravatar image

updated 2015-01-20 14:25:53 -0500

I have a custom panel, which contains a data table along with a few action links. When a single table row is selected, and an action button is clicked, I need to be able to get the object id of the selected row object. Currently, I'm doing it this way:

class SimpleAssociateIP(tables.Action):

def single(self, table, request, instance_id):

    r = request
    post = str(r.POST)
    post = post.replace("<", "{").replace(">", "}")\
        .replace("'", "\"").replace("u", "").replace("{QeryDict: ", "")\
        .replace("}}", "}")
    post_json = json.loads(post)
    print "POST:   "
    raw_id = str(post_json["object_ids"])
    id = raw_id.replace("[u'", "").replace("']", "")
    print id

This works, but I have a feeling, that there is a better way. Does anyone knows a better way to get to such object id?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-21 16:35:59 -0500

eugene.goldberg gravatar image

This is how its done: my_value = request.POST.get("my_key")

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-01-20 12:34:47 -0500

Seen: 92 times

Last updated: Jan 21 '15