title: how to prevent user from accessing a webpage without login
body: <p>I have a page called jobboard.html that I only want the super user to access.</p>
  
  <p>Right now I have created up to the point where the user can go to url /login/, enter their username and password, and then they are redirected to /activejobs/.</p>
  
  <p>However, anyone can manually type in /activejobs/ into the browser and be directed there. I am not sure how to redirect someone (who does not have permissions) that types in /activejobs/ into the browser to the login page. I have some idea of using the POST data and getting the username and password to authenticate it with the inbuilt user database Django provides but I am not sure how to do it with my current set up.</p>
  
  <p>urls.py:</p>
  
  <pre><code>    from django.conf.urls import url, include
      from django.contrib import admin
      from django.contrib.auth import views as auth_views
  
      urlpatterns = [
        url(r'^admin/', admin.site.urls),
        url(r'^login/$', auth_views.login, {'template_name': 'activejobs/login.html'}, name='login'),
        url(r'^logout/$', auth_views.logout, {'template_name': 
        url(r'^activejobs/', include('activejobs.urls')),
      ]
  </code></pre>
  
  <p>login.html:</p>
  
  <pre><code>{% extends 'activejobs/base.html' %}
  
  {% block content %}
    &lt;h2&gt;Login&lt;/h2&gt;
    &lt;form method="post"&gt;
      {% csrf_token %}
      {{ form.as_p }}
      &lt;button type="submit"&gt;Login&lt;/button&gt;
    &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p>settings.py contains this line to make it redirect to activejobs url:</p>
  
  <pre><code>LOGIN_REDIRECT_URL = '/activejobs/'
  </code></pre>
  
  <p>activejobs/urls.py:</p>
  
  <pre><code>    from django.conf.urls import url
      from . import views
  
      app_name = 'activejobs'
  
      urlpatterns = [
         url(r'^$', views.BoardView.as_view(), name='board'),
         url(r'^(?P&lt;contactId&gt;[0-9]+)/$', views.ViewContactDetails, name='detail'),
      ]
  </code></pre>
  
  <p>activejobs/views.py:</p>
  
  <pre><code>from django.shortcuts import render
  from django.views import generic
  from getrate.models import ContactInfo
  from django.contrib.auth import authenticate, login
  
  class BoardView(generic.ListView):
  
      template_name = 'activejobs/jobboard.html'
      context_object_name = 'all_jobs'
  
      def get_queryset(self):
          return ContactInfo.objects.filter(isActive = True)
  </code></pre>
  
  <p>I feel like in BoardView is where I handle the post data to authenticate the username and password, but I am not sure how to code that in.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks,</p>