[Answer]-Sending a parameter to a view

1πŸ‘

βœ…

If you don’t want to pass a parameter in the URL, you need to pass it in some other way. The only real way to do this is to use the session: set a session variable in the post view, and check it in the index one.

def process_post(request, ...):
    ... do whatever ...
    request.session['confirm'] = True
    return redirect('home')


def index(request):
    confirm = request.session.pop('confirm', None)
    if confirm:
        ...

0πŸ‘

I’m not really sure I understand the question. Are you essentially trying to do this?

(r'^your_app_view/(?P<app_value>.+)/$',views.your_view)

then in your_view you can access app_value do whatever you need and redirect to another view.

Are you then asking how to get that argument to the second view that the first view is calling?

If so then this SO answer should help you. Django return redirect() with parameters

πŸ‘€Chris Hawkes

Leave a comment