Take the tour ×  I want to create dynamic menus according to
user permissions. As was already discussed here and by the the
documentation itself, I know that I can achieve this in the
templates using the following snippet:  {% if
perms.polls.can_vote %}         <a href="/polls/vote">Vote</a>
{% endif %}  But the problem is that for security reasons I want
to limit the access to the views too. The snippet that I found
in the documentation is the following:  from
django.contrib.auth.decorators import permission_required  def
my_view(request):     # ... my_view =
permission_required('polls.can_vote',
login_url='/loginpage/')(my_view)  Isn't this against DRY
principle? Isn't there a way to define only in one place what is
the permission needed for each url? Perhaps in urls.py?
share|improve this question add comment  2 Answers  up vote 2
down vote accepted  EDIT: (See end of post for the original text
of the answer with the initial, simple idea.)  After being
kindly stricken with a cluebat (see the OP's comment