title: django decorator check if user is logged in otherwise redirect
body: <pre><code>if not request.user.is_authenticated():
      return HttpResponseRedirect(reverse('login_user'))
  </code></pre>
  
  <p>since i was doing the above, in most of my views I figured there should be something better then putting that piece in all my views. </p>
  
  <p>now i found something about decoraters that seems to do a bit what i want:</p>
  
  <pre><code>from django.views.decorators.http import require_http_methods
  
  @require_http_methods(["GET", "POST"])
  def my_view(request):
  </code></pre>
  
  <p>Now i wondered is this indeed done with decorators and if so how can i translate that to check if a user is logged in and redirect otherwise?</p>