title: Passing URL variables to a class based view
body: <p>I have just started messing with class based views and I would like to be able to access variables from the URL inside my class. But I am having difficulties getting this to work. I saw some answers but they were all so short I found them to be of no help.</p>
  
  <p>Basically I have a url</p>
  
  <pre><code>url(r'^(?P&lt;journal_id&gt;[0-9]+)/$',
      views.Journal_Article_List.as_view(), 
      name='Journal_Page'),
  </code></pre>
  
  <p>Then I would like to use <code>ListView</code> to display all articles in the particular journal. My article table however is linked to the journal table via a <code>journal_id</code>. So I end up doing the following</p>
  
  <pre><code>class Journal_Article_List(ListView):
      template_name = "journal_article_list.html"
      model = Articles
      queryset = Articles.objects.filter(JOURNAL_ID = journal_id)
      paginate_by = 12
  
      def get_context_data(self, **kwargs):
          context = super(Journal_Article_List, self).get_context_data(**kwargs)
          context['range'] = range(context["paginator"].num_pages)
          return context
  </code></pre>
  
  <p>The journal_id however is not passed on like it is in functional views. From what I could find on the topic I read I can access the variable using</p>
  
  <pre><code>self.kwargs['journal_id']
  </code></pre>
  
  <p>But I’m kind of lost on how I am supposed to do that. I have tried it directly within the class which lets me know that self does not exist or by overwriting get_queryset, in which case it tells me <code>as_view()</code> only accepts arguments that are already attributes of the class.</p>