title: Django Dynamic menu design question
body: <p>I want to create dynamic menus according to user permissions. As was already discussed <a href="https://stackoverflow.com/questions/1050653/dynamic-user-menu-in-django">here</a> and by the the <a href="http://docs.djangoproject.com/en/dev/topics/auth/#id7" rel="nofollow noreferrer">documentation itself</a>, I know that I can achieve this in the templates using the following snippet:</p>
  
  <pre><code>{% if perms.polls.can_vote %}
      &lt;li&gt;
          &lt;a href="/polls/vote"&gt;Vote&lt;/a&gt;
      &lt;/li&gt;
  {% endif %}
  </code></pre>
  
  <p>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 <a href="http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-logged-in-users-that-pass-a-test" rel="nofollow noreferrer">documentation</a> is the following:</p>
  
  <pre><code>from django.contrib.auth.decorators import permission_required
  
  def my_view(request):
      # ...
  my_view = permission_required('polls.can_vote', login_url='/loginpage/')(my_view)
  </code></pre>
  
  <p>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?</p>