django url parameters into context_processor
Asked Answered
C

2

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.

Cordova answered 9/12, 2014 at 20:43 Comment(1)
Nothing! I've no idea... I searched on Google, I red Django docs... but now I've no idea...Cordova
C
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

Caption answered 20/12, 2016 at 14:51 Comment(0)
F
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 ..

Fairfax answered 10/12, 2014 at 7:20 Comment(1)
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...)? ThanksCordova

© 2022 - 2024 — McMap. All rights reserved.