title: Passing Parameters to Django CreateView
body: <p>I am trying to implement an appointment-making application where users can create sessions that are associated with pre-existing classes. What I am trying to do is use a django CreateView to create a session without asking the user for an associated class, while under the hood assigning a class to the session. I am trying to do this by passing in the pk of the class in the url, so that I can look up the class within the CreateView and assign the class to the session.</p>
  
  <p>What I can't figure out is how exactly to do this. I'm guessing that in the template I want to have something like <code>&lt;a href="{% url create_sessions %}?class={{ object.pk }}&gt;Create Session&lt;/a&gt;</code> within a DetailView for the class, and a url in my urls.py file containing the line 
  <code>url(r'^create-sessions?class=(\d+)/$', CreateSessionsView.as_view(), name = 'create_sessions')</code>, but I'm pretty new to django and don't exactly understand where this parameter is sent to my CBV and how to make use of it.</p>
  
  <p>My plan for saving the class to the session is by overriding <code>form_valid</code> in my CBV to be:</p>
  
  <p><code>def form_valid(self, form):
          form.instance.event = event
          return super(CreateSessionsView, self).form_valid(form)</code> </p>
  
  <p>If this is blatantly incorrect please let me know, as well. </p>
  
  <p>Thank you!</p>