CoderInNetwork
CoderInNetwork

Reputation: 3093

Pass value to another view django

I searched a lot but I didn't find a working solution and I even don't know the mechanism that makes redirect between two view possible. I use

return  HttpResponseRedirect(reverse('message-inbox', args=(),kwargs={}));

It works correctly.But I want to pass some values to message-inbox's View and retrieve them in that View.I thought about passing them to request object but I don't know if this is possible and also I don't know how I can do somethings like that. I would be appreciate for any bit of help.

Upvotes: 1

Views: 2911

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

This is what the session is for.

In your source view:

request.session['my_key'] = my_value

And in your inbox view:

my_value = request.session['my_key']

Of course, if they're just small integers or strings, you could pass them in the URL parameters like any other view.

Upvotes: 6

Related Questions