Passing data between views

The redirect function takes keyword parameters in the function call.

Off-the-cuff - I’m sure my syntax is wrong on one or more items here:

in a urls.py in your urlpatterns

path('transactions/<int:portfolio_id>/', views.add_transactions, name='add-transactions'),

your view can take the portfolio_id as a parameter:

def add_transactions(request, portfolio_id):
    ...

which means you want to:

return redirect('add-transactions', portfolo_id=portfolio_id_from_form_or_wherever)
2 Likes