Q:

Redirect with arguments and message

I want to do a redirect with arguments and at the same time send a message to the redirected page.
Where to redirect:
path('companies/<int:pk>/', AccountCompanyDetailView.as_view(), name='detail_company')

from django.shortcuts import redirect

def post_view(request, id):
    return redirect('detail_company', pk=id)

I want to send to the page to wich will be redirected a 'message' to show to the user why it was redirected.
It is possible ?

A:

A very simple solution is to modify your urls.py in this way:
  url(r'^'desired_url_to_redirect/(?:(?P<error_key>[0-9]+)/)?$', views.'name_of_your_view', name='name_of_your_view'),

The second parameter is optional and would act as a key for the type error. The only thing left would be to update your template to present the desired message based on the type of error.
For defining your view don't forget to insert as a second parameter 'error_key=None' 

