django url parameters into context_processor

870 views Asked by At

I have this Django Url:

url( r'^(?P<language>.*)/(?P<shop>.*)/(?P<brand>.*)/$', 'app.views.view_1' ),

Now, "language", "shop", "brand" are all parameters into my url and I want to read them into my custom Django Context Processor. How can I do it?

Thanks.

2

There are 2 answers

0
Harel On

You can access request.resolver_match from the context processor. This will give you access to the resolved url parameters in request.resolver_match.kwargs

1
Raja Simon On

I just tell you the idea here. When the url calls view_1 function , you have language, shop, brand values ... here why don''t you set that values into session and get that values in Context Processor using session variable ..