title: How do I get the current user for my created_by field in Django 1.9?
body: <p>I'm trying to pull the session user into my model's save() method.  <a href="https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.user" rel="nofollow">The docs for HttpRequest</a> and all the examples I've found assume you already have the object instanciated, but I can't seem to find a method that will do the instanciation.  </p>
  
  <p>I'm thinking I should be using <code>HttpRequest.user</code> , but I don't know how to generate the instance in my model so I can actually do it.</p>
  
  <p>Here's my save() override.  It generates <code>type object 'HttpRequest' has no attribute 'user'</code>, but considering this is a class and not an object reference that isn't really surprising.:</p>
  
  <pre><code>def save(self, *args, **kwargs):
      ''' On save, update timestamps '''
      if not hasattr(self, 'id'):
          self.date_created = timezone.now()
          self.created_by = HttpRequest.user
  
      self.last_updated_date = timezone.now()
      self.last_updated_by = HttpRequest.user
  
      super(Caregiver, self).save(*args, **kwargs)
  </code></pre>
  
  <hr>
  
  <p>views.py added for more info</p>
  
  <pre><code>class CaregiverCreateView(CreateView):
      template_name = 'single_form_generic.html'
      model = Caregiver
      form_class = CaregiverCreateForm
  </code></pre>