title: Possible to use decorators in django to do permissions based on a view parameter?
body: <p>I'm not sure it's possible, but is there a way to write something like</p>
  
  <pre><code>@group_required('group_id')
  def myview(request, group_id):
      .....
  </code></pre>
  
  <p>Where I look at the value of the parameter group_id and limit access to this view to only people who are in this group?</p>
  
  <p>I know it is possible to create a decorator to check membership in some specific group</p>
  
  <pre><code>@group_required('admin')
  def myview(request):
     ....
  </code></pre>
  
  <p>But say I want a view that is only accessible to people within a certain group, which is determined by the url.</p>
  
  <p>So for example</p>
  
  <pre><code>/group/1
  /group/2
  </code></pre>
  
  <p>Should each have permissions so that only members of group #X can see that page. I can easily write this functionality within the view</p>
  
  <pre><code>group = get group
  if user not in group
      raise 404
  </code></pre>
  
  <p>but that logic is repeated all over. Decorators seems like a promising way to do it, but it seems the scope is backwards. Is there another preferred way to handle this sort of permissions?</p>
  
  <p>Thanks!</p>