title: Automatically populate a model field with FK to User in Django
body: <p>I have this small models.py file:</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code># -*- coding: utf-8 -*-
  import datetime
  
  from django.db import models
  from django.contrib.auth.models import User
  
  from apps.strumento.models import Strumento, Veicolo
  
  class AllegatoStrumento(models.Model):
      allegato = models.FileField(upload_to='uploads_strumento/', blank=True, null=True)
      data_creazione = models.DateTimeField(default=datetime.datetime.now)
      creatore = models.ForeignKey(User)
      strumento = models.ForeignKey(Strumento)
  
      class Meta:
          verbose_name_plural = "Allegati strumenti"
          verbose_name = "Allegato strumento"
  
      def __unicode__(self):
          return str(self.allegato)
  </code></pre>
  
  <p>I would like the 'creatore' field to be automatically populated with the logged user triggering the save/update action, so that I can display it but not allow it to be altered directly.</p>
  
  <p>OF course, just putting the User FK like this in the model, it asks me which user to put in, which I don't want to happen.</p>
  
  <p>I've tried with both these lines:</p>
  
  <pre><code>creatore = models.ForeignKey(User, default=request.user.get_username())
  creatore = models.ForeignKey(User, default=User.get_username())
  </code></pre>
  
  <p>but none of them work, as the first misses an instance of <em>request</em> while the second complains that the method is <strong>NOT</strong> (corrected, thanks @bruno desthuilliers) being called on an instance ("<em>TypeError: unbound method get_username() must be called with User instance as first argument (got nothing instead)</em>")</p>
  
  <p>What could an easy way for doing that be?</p>