0

I have a url(r'^manager/', include('manager.urls')) and I want only logged in users can access it. So, I tried to write url(r'^manager/', login_required(include('manager.urls'))), but it throws

TypeError at /manager/

'tuple' object is not callable

Is there other way to implement it or should I write @login_required decorator for every view in manager.views.py?

Andrew
  • 423
  • 1
  • 6
  • 16

1 Answers1

0

login_required is a decorator, meaning that it requires a function, in contrast to the include() function which returns a tuple of urls.

As a simple solution I would recommend you to apply the decorator on each individual url within the file managers.url.

Otherwise take a look at Best way to make Django's login_required the default.

Community
  • 1
  • 1
Wtower
  • 18,848
  • 11
  • 103
  • 80
  • regret... how about DRY? :( – Andrew May 20 '15 at 11:25
  • Ok, I edited it for you to get some not-so-elegant alternatives. But do you really want to get involved into that I wonder. Personally, I don't find a `login_required` call to each url much of a repeatition to bother myself. – Wtower May 20 '15 at 11:31