6

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 Answers2

7

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

Harel
  • 1,989
  • 3
  • 26
  • 44
0

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 ..

Raja Simon
  • 10,126
  • 5
  • 43
  • 74
  • The call chain (correct me if I'm in wrong) is: url -> context_processor -> view_1. So, how and where can I set session attributes (language, shop, etc...)? Thanks – Gabriele Morgante Dec 10 '14 at 15:23