Ask Your Question
0

how to properly extract selected object id from a table

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

eugene.goldberg gravatar image

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

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?

-Eugene

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

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

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

Stats

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

Seen: 102 times

Last updated: Jan 21 '15