Gabriele Morgante
Gabriele Morgante

Reputation: 69

django url parameters into context_processor

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.

Upvotes: 6

Views: 921

Answers (2)

Harel
Harel

Reputation: 2039

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

Upvotes: 7

Raja Simon
Raja Simon

Reputation: 10305

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

Upvotes: 0

Related Questions