title: Django - CreateView - How to declare variable and use it in templates
body: <p>How do I declare a variable in Django's Createview, so I can use it from its template?
  For example I want to use {{ place_slug }} in the template. I pass that from urls.py like below:</p>
  
  <p>urls.py:</p>
  
  <pre><code>urlpatterns = patterns('',
      (r'^new/(?P&lt;place_slug&gt;[\w\-\_]+)/?$', PictureCreateView.as_view(), {}, 'upload-new'),
  )
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>class PictureCreateView(CreateView):
      model = Picture
  
      def dispatch(self, *args, **kwargs):
          self.place = get_object_or_404(Place, slug=kwargs['place_slug'])
          return super(PictureCreateView, self).dispatch(*args, **kwargs)
  
      def form_valid(self, form):
          more code here
  </code></pre>