Paul R
Paul R

Reputation: 2797

How to attach decorators to include in urls.py?

It is valid to write:

url(r'^/signup$', my_decorator(my_view), name='sign up')

How to write the same for includes?

url(r'^admin/', include(admin.site.urls)) # where to write my_decorator?

Is this problem solvable only with the help of request?

Upvotes: 0

Views: 47

Answers (1)

Alasdair
Alasdair

Reputation: 308789

There isn't a straight forward way to do this. The url pattern that uses include has no access to the view to decorate it.

You could try writing a modified version of include that decorates any included url patterns. This might be tricky, because the included url patterns could use include again.

Upvotes: 1

Related Questions